Saturday, 6 June 2015

When should i use Response.Redirect(url,false) in C# code

What is the use of True and False in Response.Redirect? First parameter in Response.Redirect define redirection to next page but true/false tells whether to stop or continue processing the next line.

True or False parameter in Response.Redirect tells whether to continue the code execution or terminate the next line execution on that page.

Look at below piece of code.
In below code, after Response.Redirect for loop execution will continue.

Response.Redirect("Page.aspx",false);
        for (int i = 0; i < 10; i++)
        {
            i++;
        }



In below code, after Response.Redirect for loop execution will be terminated.

Response.Redirect("Page.aspx",true);
        for (int i = 0; i < 10; i++)
        {
            i++;
        }

No comments:

Post a Comment

Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks