Do I need to call return statement after a Response.Redirect method ?
-
Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.Redirect(ResolveUrl("~/Projects"));
return;
}int x = 5; int y = 4; doSomething(x,y); }
Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.
-
Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.Redirect(ResolveUrl("~/Projects"));
return;
}int x = 5; int y = 4; doSomething(x,y); }
Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.
I am not sure,but there is no need of return statement after the response.redirect();
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.Redirect(ResolveUrl("~/Projects"));
return;
}int x = 5; int y = 4; doSomething(x,y); }
Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.
-
Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.Redirect(ResolveUrl("~/Projects"));
return;
}int x = 5; int y = 4; doSomething(x,y); }
Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.
If You want to be Dobly Sure use this
Response.Redirect(ResolveUrl("~/Projects"),true);
This will end the excecution of Current page ..... No Need of using Return
-
Hi, In my asp.net web form's page_load event, I want to check if the query string 'id' is there or not. If not, then transfer the user to another page. Now, I am using this code.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.Redirect(ResolveUrl("~/Projects"));
return;
}int x = 5; int y = 4; doSomething(x,y); }
Now, my question is, DO I NEED TO CALL THE 'return' STATEMENT after Response.Redirect(ResolveUrl("~/Projects")); call ? Wont the page automatically die after this Redirect method call ? Thanks.
Is that the problem that you are afraid that below code will execute after Response.Redirect executes, isnt it? so dont be afraid. if the program reaches that Response.Redirect line, it normally stop executing that process and pass the control to next process, it will never execute below coding int x = 5; int y = 4; doSomething(x,y);
-
Is that the problem that you are afraid that below code will execute after Response.Redirect executes, isnt it? so dont be afraid. if the program reaches that Response.Redirect line, it normally stop executing that process and pass the control to next process, it will never execute below coding int x = 5; int y = 4; doSomething(x,y);
Thanks San for your helpful answer.