Asp.net Error Statuscode= 401
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the web.config httperrors workings and policies of this site About Us Learn more about Stack customerrors 401 not working Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs asp.net mvc custom 401 page Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; asp.net mvc authorize redirect to login it only takes a minute: Sign up Redirect unauthorized users asp net up vote 9 down vote favorite I'm working on a simple website in asp.net. I would like to restric access to the side, so that only users in a specific AD group is allowed. I have done that and it is working fine. But when a user
Web.config Redirect
that's not in the AD group tries to access the site, they are getting a login prompt. How do I redirect the unauthorized user to a custom page, instead of they getting the login prompt? Below is my web.config. The lowest part of the code, is something i tried but did not work.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Http Error Codes
of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/18652934/redirect-unauthorized-users-asp-net Sign up ASP.NET MVC4 error handling for 404, 401 and other exceptions up vote 3 down vote favorite I'm struggling to understand how to correctly handle errors in ASP.NET MVC4. As an example, I've created a new MVC4 project using the "Internet Application" template and updated my home controller to test out some error cases: public class HomeController : Controller { public http://stackoverflow.com/questions/13607543/asp-net-mvc4-error-handling-for-404-401-and-other-exceptions ActionResult Index() { ViewBag.Message = "Hello"; return View(); } public ActionResult About() { throw new HttpException(401, "Not Authorized"); } public ActionResult Contact() { throw new Exception("Oh no, some error occurred..."); } } I have enabled customErrors in my web.config file:
Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog http://www.codeproject.com/Articles/11202/Redirecting-to-custom-page-when-quot-Access-de quick answersQ&A Ask a Question about this article Ask a http://serverfault.com/questions/458394/iis-7-5-how-to-configure-custom-authentication-error-page-with-windows-authenti Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript asp.net mvc C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions asp.net error statuscode= News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Articles » Web Development » ASP.NET » General ArticleBrowse CodeStatsRevisionsAlternatives Comments (30) Add your ownalternative version Tagged as HTMLC#.NET1.1.NET2.0Windows.NET1.0VS2005ASP.NETVS.NET2003Dev Stats 238.8K views2K downloads44 bookmarked Posted 2 Aug 2005 Redirecting to custom 401 page when "Access denied" occures within an ASP.NET application with Windows authentication George Mamaladze, 3 Aug 2005 4.87 (16 votes) 1 2 3 4 5 4.87/5 - 16 votes2 removedμ 4.32, σa 1.86 [?] Rate this: Please Sign up or sign in t
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top IIS 7.5: How to configure custom Authentication Error page with Windows Authentication. 401 header problems up vote 12 down vote favorite 4 I have a php website running under IIS 7.5. The site is secured by Windows authentication and that works fine: When users go to the site, they are asked for username/password and get through if authenticated. If users click Cancel or mistype password 3 times, they are shown 401 error page: Now I would like to show custom page explaining how to log-in. So I go to Error pages, select status code 401.2 and point it to the page I would like to display: Then make sure the custom errors are turned on for everybody. And kaa-boom! Authentication does not work any more, users are not presented with the password prompt. As documentation says, Windows Authentication works by sending 401 reply first, then browser asks user to provider credentials and then they work out what to do next. What happens here: on first request for the page IIS tries to send 401-header, but notices that web.config says "on 401 redirect to this page". And instead of authentication, it just gives the redirect page. I've tried replacing 401, 401.1, 401.2 - made no difference. What am I doing wrong and how to give custom page on user authentication error? p.s. Here is the web.config: