Response.Redirect in Page_Load

teledextri picture teledextri · Dec 14, 2013 · Viewed 19.7k times · Source

I have a Response.Redirect in my Page_Load:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    ...Code
    Response.Redirect("http://www.mysite.com")
End Sub

I have other Subroutines with working code before adding the Response.Redirect

When the Response.Redirect is added they all do not process their code and automatically execute the Response.Redirect website.

My code works when there is no Response.Redirect.

Answer

Damith picture Damith · Dec 14, 2013

Use

Response.Redirect("http://www.mysite.com",  false)

second parameter Indicates whether execution of the current page should terminate or not.

if you use Response.Redirect("http://www.mysite.com"), current page execution will terminate