I am trying to implement "Sign in as different user" on windows authentication asp.net web site.
I followed this blog Sign in as Different User. Everythig is fine except Cancel
button.
When user requested for userid/password dialog box. If I hit cancel
button. it stays at Access denied
page.
But I want redirect IIS access denied 401 page. How to do that?
Handle the Application_EndRequest in the global.asax file. A piece of information from the article linked below (not my code):
protected void Application_EndRequest(Object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
if (context.Response.Status.Substring(0,3).Equals("401"))
{
context.Response.ClearContent();
context.Response.Write("<script language="javascript">" +
"self.location='../login.aspx';</script>");
}
}
Take a look here for the full-article
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With