Getting Some 401 - Unauthorized Exception When Going to My ASP.NET MVC Website

I am running a simple web application using ASP.Net MVC 3.

I made several pages, mainly for authentication, which uses authentication from custom providers and asp.

On my local Visual studio server, it works fine when I go to the page with the [Authorize] attribute, I am redirected to my login page, and after I registered, I can visit this page without any problem.

I published via FTP my site on a dedicated server (on my local network), and now when I go to the site, I am redirected to the login page, but instead of getting the login page, I get a 401 Unauthorized exception.

Edit: Refine my login page / Account / Auto / Login if I try to access something (e.g. / OtherArea / OtherController / OtherAction, I redirect to / Account / Auth / Login, but it shows me error 401 )

This is the same problem if I try it locally on the server or on my desktop.

I have the same web.config file, no other authentication mode is enabled, the user of my application pool has full control over the directory. What could be wrong?

I have included a detailed error, and I only get the following data:

You do not have permission to view this page due to invalid authentication headers.

Is there a prerequisite for installing in addition to asp.net 4 + publish? Does publishing publish all necessary asp.net dll files?

+4
source share
1 answer

Check web.config settings for system.web / authorization; you must either not have this element at all, or it should only contain <allow users="*"/> MVC uses its own logic (AuthorizeAttribute) to determine what the anon user can access (or not). Web.config settings should not run into this.

Check to see if anonymous authentication is enabled in IIS for this website. In addition, forms authentication must also be enabled, and all other auth modes (if installed) must be disabled.

+5
source

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


All Articles