I am using IIS Express to deploy MVC4 application. This website runs perfectly on same computer. But in Lan it gives me error 401.
<authentication mode="Forms">
<forms loginUrl="~/" slidingExpiration="true" timeout="20">
</forms>
</authentication>
In home controller
[HttpPost]
[AllowAnonymous]
public ActionResult Index(LoginModel model, string returnUrl)
{
}
I am starting IIS server from command prompt in Administrator mode. IIS responds to the request with error 401
.
Any clue?
This question is related to
asp.net-mvc
iis
http-status-code-401
form-authentication
I had a slightly different problem. The credential problem was for the underlying user running the application, not the user trying to login. One way to test this is to go to IIS Management -> Sites -> Your Site -> Basic Settings -> Test Settings.
I realize this is an older post but I had the same error on IIS 8.5. Hopefully this can help another experiencing the same issue (I didn't see my issue outlined in other questions with a similar title).
Everything seemed set up correctly with the Application Pool Identity, but I continued to receive the error. After much digging, there is a setting for the anonymous user to use the credentials of the application pool identity or a specific user. For whatever reason, mine was defaulted to a specific user. Altering the setting to the App Pool Identity fixed the issue for me.
Hopefully this saves someone else some time!
I had a permissions issue to a website and just couldn't get Windows authentication to work. It was a folder permissions rather than ASP.NET configuration issue in the end and once the Everyone
user was granted permissions it started working.
I faced this error when I created an empty project with the MVC folders and then deployed the application to the server. My issue was that I didn't define the authentication in Web.config
, so all I had to do was add this line to a system.web
tag.
<system.web>
<authentication mode="None"/>
</system.web>
In case anyone is still looking for this, this solved the problem for us:
To whoever this may help, this saved my life...
IIS 7 was difficult for figuring out why i was getting the 401 - Unauthorized: Access is denied due to invalid credentials... until i did this...
I faced similar issue.
The folder was shared and Authenticated Users permission was provided, which solved my issue.
Make sure that you enabled anonymous authentication on iis like this:
In my case, what made it work was changing the Anonymous User identity from Specific user (IUSR) to Application Pool Identity. Weird enought because other sites are using the specific user IUSR and work fine.
I realize its an old question, but this came up in my searches. Had a similar issue for an MVC application recently built, deployed for the first time, and Authentication mechanism wasn't completely hashed out.
It wasn't an IIS setting in my case, it was a Controller that was not [AllowAnonymous]
decorated. I was using a Render.Action/Html.Action in a Layout.cshtml and the User was unauthenticated. So the Layout tried to load an Authenticated Action in an UnAuthenticated context.
Once I updated the action to AllowAnonymous, the problem went away, and this is what led me to it.
Hope this helps someone.
i faced the same issue under IIS 8.5. A working solution for me was changing the IIS to display detailled errors. See answer from sna2stha. But i think it is not a good idea to forward detailed error messages to browsers in production enviroments. I added/changed the existingResponse attribute in the httpErrors-Section, so the IIS not handled any extisting Asp.net Response:
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
This works for me.
I had this issue on IIS 10. This is how I fixed it.
In my case,
My application is developed in MVC
and my home controller class was decorated with [Authorize]
which was causing this issue.
So I've removed it because my application don't require any authentication.
If you're using IIS 7 do something like this:
I had a similar issue today. For some reason, my GET request was fine, but PUT request was failing for my WCF WebHttp Service
Adding the following to the Web.config solved the issue
<system.web>
<authentication mode="Forms" />
</system.web>
Source: Stackoverflow.com