How to Redirect a Web Page in ASP.NET

How to Redirect a Web Page in ASP.NET thumbnail
Redirect a web page in ASP.NET.

ASP.NET was created by Microsoft to give programmers a platform to create dynamic websites, applications and services. Microsoft first released ASP.NET in January 2002, but it didn't become stable until August 2008. You can do several web functions in ASP.NET, including redirecting a web page to another web address. You will only need to add a few lines of code to your current ASP.NET code.

Things You'll Need

  • Web-authoring application (like Dreamweaver) or Notepad
Show More

Instructions

    • 1

      Open an existing ASP.NET file or start a new one in your current web-authoring program or in a text tool like Notepad.

    • 2

      Add the redirect code to a method:

      Response.Redirect("http:\\www.mysite.com")

      If you would like the redirect to happen after a visitor clicks on a button, the code will look like this:

      Sub RedirectButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs)
      Response.Redirect("http:\\www.mysite.com")
      End Sub

    • 3

      Save the ASP.NET file and upload it to your server.

Tips & Warnings

  • To have the redirect method start automatically when a web page opens, add the code to the "Load" event of the page.

  • Another method that works is the "Transfer" method. The code for that is:

  • Server.Transfer("http://www.mypage.asp", True)

  • Just add the code to the event you want, such as a page load or a button click.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured