Will Response.Redirect in Loop will break the loop and stop execution in C# .Net?

Last Reply on Oct 15, 2015 02:19 AM By Shashikant

Posted on Oct 15, 2015 02:08 AM

Give me an explanation.

int i = 0;
while (i < 5)
{
    if (i == 3)
    {
        Response.Redirect("Default1.aspx");
    }
    i++;
}
Posted on Oct 15, 2015 02:19 AM

Hi,

The code, you have written will end the current response.to countine the while loop you need to set endResponse parameter of Redirect method to false.

Code

int i = 0;
while (i < 5)
{
    if (i == 3)
    {
        Response.Redirect("Default1.aspx",false);
    }
    i++;
}

I hope this will help you out.

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html