Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

401 Unauthorized: Access is denied due to invalid credentials

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?

like image 632
java.manish.2015 Avatar asked Nov 07 '12 22:11

java.manish.2015


People also ask

Why does it say 401 unauthorized?

The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.


2 Answers

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.

  1. IIS Manager → Sites → Website
  2. Double click "Authentication"
  3. Select Anonymous Authentication
  4. From the Actions panel, select Edit
  5. Select Application pool Identity and click ok

Hopefully this saves someone else some time!

like image 155
ctc Avatar answered Sep 29 '22 04:09

ctc


If you're using IIS 7 do something like this:

  1. Select your site.
  2. Click on error pages.
  3. Edit feature settings.
  4. Select detailed errors.
like image 35
Suraj Shrestha Avatar answered Sep 29 '22 04:09

Suraj Shrestha