ASP.MVC Windows Authentication HTTP Error 401. The requested resource requires user authentication - asp.net-mvc

I have an ASP.NET MVC application using windows authentication that I published by visual studio on a windows 2008 server.
But when I try to reach the application from a browser I have to authenticate I get the default authentication form to do this.
If I type my user name and password I can not reach my application but if I use the administration account the application will be displayed in the browser.
And other strange things... in the IIS server I select the application site and click basic settings.
I click on the test connection button I get the following error message:
"Invalid application path".
But if I click the connect as button and use the administration account the test is passed successfully.
Anybody can help me?
l.

Related

When browse from web server, Windows authentication not working

I have two servers,
WEB01_Server
APP01_Server
So my ASP.NET MVC application has two Projects
Sample_Web
Sample_Service
So my application architecture like following
so both these projects I hosted in APP01_Server So I enable the windows authentication(using IIS) for Sample_Web project and once I browse this web project in App server URL windows login prompt coming and successfully able to log in.
Once I browse with WEB01_Server URL, it also windows AD login prompt coming and but cannot log in.
Additionally, I enabled Windows authentication in WEB01_Server this application IIS web site instance and result is same.
Configuration wise What else I need to configure ?

ASP.NET MVC 4.5 - The issue with the Logon user (HttpContext.Request.LogonUserIdentity.Name)

I am developing an ASP.NET MVC 4.5.1 application using VS 2013.
Following are the settings at the IIS 7.5
Windows Authentication Enabled (also in Web.config authentication mode is set to "Windows").
Anonymous Authentication Disabled.
Application pool is running with service account "contoso\john".
The mode is Integrated.
On my landing page (e.g. HomeController.cs) I am storing logon user information as below:
Session["LogonUserName"] = HttpContext.Request.LogonUserIdentity.Name and that's working fine, I can use the Session["LogonUserName"] from other views.
However, when redirecting from home page to a different view e.g. Customer View something weird is happening and somehow I am losing the authentication and I am not able to step into a function.
So I Disabled the Windows Authentication and Enabled the Anonymous Authentication but then on the customer view page I am getting HttpContext.Request.LogonUserIdentity.Name = "NT AUTHORITY\IUSR"
and Session["LogonUserName"] = contoso\john, which is my app pool account.
Any idea why? Could someone please help me?
Ok. The issue certainly due to be authentication (XSS problem) and the JavaScript code wasn't being trusted when running on localhost or on IP address. When given a DNS entry (site binding) the issue resolved.

MVC internet application(iis express worker process is closing)

I have created ASP.NET MVC project using internet template. Then I have enabled external(facebook) authentication in AuthConfig file. Now when I run my project and get authenticated with facebook it is working just fine, but the problem is that associated iis express worker process is just closing approximately within 1 minute and VS debugging stops(as if I manually press the Shift+F5). I am getting no errors at all. This doesn't happen when I run the project with Chrome or if I just don't authenticate when using Internet Explorer. It only happens in Internet Explorer when I am authenticating with facebook.
Can anyone suggest what is going on?
Several observations:
when I am authenticated with local account problem doesn't occurs.
when I am authenticated with facebook it redirects to
http://localhost:27264/#_=_. May be #_=_ this is the problem?

Window authentication not working in MVC4

Scenario
User A can access all pages in MVC4 website except one. But user B can access all pages (no restriction).
What I had done so far?
Deployed website on IIS 7.5.
Enabled window authentication and disabled Anonymous authentication for hosted website on IIS.
Testing website.
Testing Results -
(1) When User B is logged on same system (development system) where the website is deployed, he can access the website without prompt dialog.
(2) But when same website is published on server (production system) with same settings, website still asks for credentials with pop up.
** Both of the development system and production system are in same domain (let's name it domain.com).
Question
Why is the same user in same domain is been asked for credentials by website?
As per my research for Window Authentication, I want to conclude following lines (also as reference for me) -
(1) Window Authentication (abbrev. WA) will always show prompt for verifying users if you had configured WA properly.
See anonymous authentication disabled and windows authentication enabled in below snapshot.
(2) Even if one set NTLM as top provider than Kerberos (in IIS), the IIS will still ask for Window credentials. Snapshot show how to do that.
(3) If you want to avoid showing prompt on browser for WA, follow steps-
(a) Open IE browser --> Internet Options --> Security tab.
(b) Add site to Local Intranet zone so that browser will send logged-in username and password to IIS.
Note - The above points universally apply to MVC and ASP.NET.
Answer to my question Why is the same user in same domain is been asked for credentials by website?
Because I had set anonymous authentication enabled along with Window authentication on development system. (Silly mistake).

SharePoint Products & Technologies Configuration Wizard : System.FormatException

I am configuring the Sharepoint for the first time, using the SharePoint Products & Technologies Configuration Wizard. While configuring, i have selected below options:
I am creating a new server farm.
Entered the my machine name as database server name, and specified
the credentials of domain user. This domain user is added to the
login user on my database server with Windows Authentication.
Specified the port number 10100 and selected NTLM authentication
provider.
After clicking Next i am getting below error:
An error has occurred while validating the configuration settings. An exception of type System.FormatException was thrown. Additional exception information: *Input string was not in a correct format.*
In the event viewer no error has been logged. But few Information level logs are logged stating 'Login failed for user ''. Reason: Failed to open the explicitly specified database. [CLIENT: *..*.]'. But i can login to database with the same user with Windows Authentication.
Please suggest few things to resolve this issue.
Thanks.
I came across with same issue. I Did rein-stallion of SQL 2008 R2 with SP1 and reinstalled IIS on SharePoint server. Then issue got fixed.

Resources