Tuesday, February 17, 2009

Redirect a page URL in javascript

The following code will redirect a page from index.aspx to the root URL in javascript:

var u = 'http://www.mysite.com/';
if (self.parent.frames.length != 0) self.parent.location=u;
if (self.location != u) self.location=u;//

Monday, February 16, 2009

301 Redirect in ASP.NET / C# Code

If you want to redirect a URL on a permanent basis using ASP.NET and C# code as an alternative to using IIS 6 or IIS 7, you can append the code to the old ASP.NET page.


Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "http://www.newpagelocation.com/");
Response.End();

Hope this helps!