Question

Comment puis-je rediriger en permanence dans ASP DOT NET? J'aimerais faire une redirection 301 d'une page de mon site vers une autre page.

Était-ce utile?

La solution

protected void Page_PreInit(object sender, EventArgs e)
{
    Response.StatusCode = 301;
    Response.StatusDescription = "Moved Permanently";
    Response.RedirectLocation = "AnotherPage.aspx";
    HttpContext.Current.ApplicationInstance.CompleteRequest();
}

Et dans la version 4.0, il existe un simple HttpResponse.RedirectPermanent () <) méthode qui fait tout ce qui précède pour vous:

Response.RedirectPermanent("AnotherPage.aspx");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top