Avatar of wiggy353
 asked on

web app on IIS 7 login error

I have a web app that I made in Visual Studio 2010. It works fine when testing in visual studio. I have put it on an IIS 7 web server and am having problems. The error I am getting is:

Login failed for user 'MASTER\PIGSTEST$'.

The code that I have in the app to get the user is:

        protected void Page_Load(object sender, EventArgs e)
            string userName;
            string userDomain;
            string user = HttpContext.Current.User.Identity.Name.ToString();
            string[] usernameArray = user.Split('\\');
            userDomain = usernameArray[0];
            userName = usernameArray[1];

            lblPbmSiteMasterUserName.Text = userName.ToString();
            string versionInfo = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            lblBuildVersionPbmSite.Text = versionInfo;

Open in new window

The username that it is showing in the error isn't my user name when going to the page. The domain is correct, but the username is the name of the computer that is the webserver with a $ on the end. I'm not sure what's happening here...

Microsoft IIS Web ServerASP

Avatar of undefined
Last Comment

8/22/2022 - Mon
Matthew Kelly

Open up the computer manager and see what account is setup to run the Application Pool of the IIS website instance. Additionally, check to see what Authentication is specified on the site. The default is "Anonymous", where you probably want "Windows authentication".
Matthew Kelly

It really just sounds like you have Anonymous authentication enabled, so if you disable that and enable Windows, that should work.


User Interface
1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
2. In Features View, double-click Authentication.
3. On the Authentication page, select Windows Authentication.
4. In the Actions pane, click Enable to use Windows authentication.

As long as you are running on a server product you are fine. As noted "Windows Authentication is not supported Home or Starter editions of Windows Vista® and Windows® 7"

I was thinking that might be it, but I have it set to Windows authentication.
Your help has saved me hundreds of hours of internet surfing.

I created a test site that uses the same code to get username information. It works fine using the default application pool, but if I change it to the .NET 4.0 application pool it does not work any more. The only difference that I can see is the version of the .NET framework. Is there something in the 4.0 framework that conflicts with the code?

Something this simple:

    protected void Page_Load(object sender, EventArgs e)
        Response.Write("Current User: <strong>" + System.Environment.UserName + "</strong><br><br>");
        Response.Write("Current User: <strong>" + HttpContext.Current.User.Identity.Name.ToString() + "</strong>");

Open in new window

Is braking when I set the .Net Framework to 4.0. It works fine in 2.0...???
Matthew Kelly

What is the identity of the .NET 4.0 app pool? If you go to the Application Pools and click Advanced Settings, there is a field called "Identity". Try setting that to "AppPoolIdentity", as that user has the default permissions required.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

It was set to Network. I changed it to ApplicationPoolIdentity but it didn't make a difference. The error I get when going to the page is:

Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I found this answer somewhere else.