IMG-LOGO

301 Redirect Page in ASP.Net C#

andy - 02 Aug, 2013 8919 Views 0 Comment

When you build a new website, you want to make sure that you perform 301 redirect page for each individual link or page. Otherwise your old site links and information are no longer available in Google search and this can be bad for your site ranking.

This quick code snippet will show you how you can perform 301 Redirect Page in ASP.Net C#. Note: you may want to alter the redirect url and include some cases to suit your requirement.

private void Page_Load (object sender, System.EventArgs e){   
   string redirectURL = "https://bytutorial.com";
   Response.Status = "301 Moved Permanently";  
   Response.AddHeader("Location", redirectURL);
}

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.

Related Articles

How to remove html tags from string in c#?

Sometimes you need to remove HTML tags from string to ensure there are no dangerous or malicious scripts especially when you want to store the string or data text into the database.