0

I created the sample for role authentication in asp.net 2005. I created the login panel on my default.aspx page and after login it works fine. Iused the code as below for login

FormsAuthentication.RedirectFromLoginPage(txtUName.Text, true, urlpath);
FormsAuthentication.SetAuthCookie(txtUName.Text, true);
Response.Redirect(urlpath, false);

I used all required page links in a single master page that is shown after login. I used the code in master page for "logout" like below on clicks of link button

 try
 {
      Response.Redirect("~/Logout.aspx" );
 }
 catch (Exception ee)
 { 
      return;
 }

Now when I logout from master page I got an error like this

unable to evaluate expression because the code is optimized or native frame is on top of call stack

I have goggled but not got the solution. I am unable to find-out the reason behind this. Please provide the proper solution. Thanks

Ghost Answer
  • 1,458
  • 1
  • 17
  • 41

1 Answers1

2
http://support.microsoft.com/kb/312629/en-us

To work around this problem, use one of the following methods: •For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass the code execution to the Application_EndRequest event.

•For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example: Response.Redirect ("nextpage.aspx", false);

If you use this workaround, the code that follows Response.Redirect is executed. •For Server.Transfer, use the Server.Execute method instead.

tam tam
  • 1,870
  • 2
  • 21
  • 46