LearnFast.Ninja

301 redirect .NET C#

How to use the 301 header for redirect to another page. Note that this method is common when dealing with SEO. It is important to stop execution of the page by using the End function.

Example:

protected void Page_Load(object sender, EventArgs e)

{

    string id = Request.QueryString["id"].ToString();

 

    if (id == "6")

    {

        Response.Status = "301 Moved Permanently";

        Response.AddHeader("Location""http://www.thebestdata.com");

        Response.End();

    }

}


Tags

asp.net

301 redirect header add-header end