How do I redirect permanently in ASP DOT NET? I'd like to do a 301 redirect from one page on my site to another page.
301 is an HTTP status code sent by a web server to a browser. A 301 signals a permanent redirect from one URL to another, meaning all users that request an old URL will be automatically sent to a new URL.
Permanently redirect old pages or entire folders of pages to new locations in your Webflow site using the 301 Redirects settings: Open Project settings > Hosting > 301 redirects Add the old URL in the “Old Path” field (eg. /old-url) Add the new URL in the “Redirect to Page” field (/entirely/new-url/structure)
For permanent changes to a website and continued ranking through SEO, a 301 redirect is necessary. On the other hand, if you're only performing a temporary change, a 302 redirect is better. It tells the search engine that the changes are temporary and may not impact the original page's SEO ranking.
protected void Page_PreInit(object sender, EventArgs e)
{
Response.StatusCode = 301;
Response.StatusDescription = "Moved Permanently";
Response.RedirectLocation = "AnotherPage.aspx";
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
And in 4.0, there's a simple HttpResponse.RedirectPermanent()
method that does everything above for you:
Response.RedirectPermanent("AnotherPage.aspx");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With