Why does this page not redirect work in IE?

I check the session variable on my asp.net page and redirect to the default page.

 if (Session["OrgId"] != null)
   {
       // some logic
   }
 else
   {
             Response.Redirect("../Default.aspx?Sid=1", false);
   }

and on my default.aspx page, I did this,

Int64 id = GetId(Request.RawUrl.ToString());
  if (id == 1)
 {
    // I ll show "Session Expired"
 }

public Int64 GetId(string url)
{
    Int64 id = 0;
    if (url.Contains("="))
    {
        if (url.Length > url.Substring(url.LastIndexOf("=")).Length)
        {
            id = Convert.ToInt64(url.Substring(url.LastIndexOf("=") + 1));
        }
    }
    return id;
}

This works in googlechrome, firefox, but not in IE. Operation exception aborted.

+3
source share
3 answers

try changing

 Response.Redirect("../Default.aspx?Sid=1", false);

to

 Response.Redirect("../Default.aspx?Sid=1"); 

or

Response.Redirect("../Default.aspx?Sid=1", true);
+3
source

HttpResponse.Redirect Method

Redirect(String, Boolean)Redirects the client to the new URL. Specifies a new URL and the execution of the current page should stop.

This means that the Response.Redirect("../Default.aspx?Sid=1", false);current response will not complete.

+2
source

IE is much more sensitive than other browsers about changing the DOM after sending headers, but before the page ends.

Here is your problem:

Response.Redirect("../Default.aspx?Sid=1", false);

Try changing false to true.

Also, be very careful with the cover in the names of your pages. "Default.aspx" and "default.aspx" are not really the same page, even if Windows allows you to handle it.

0
source

Source: https://habr.com/ru/post/1758913/


All Articles