Log in as another user in asp.net?

I am trying to implement "Log in as a different user" on the asp.net Windows authentication website. I followed this blog. Log in as Miscellaneous . User . Everythig is excellent except the Cancel button. When the user asks for the userid / password dialog box. If I clicked Cancel . it stays on the Access denied page.

But I want to redirect access to IIS denied 401 page. How to do it?

+6
source share
1 answer

Process Application_EndRequest in global.asax file. Part of the information from the article 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.

+1
source

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


All Articles