tags:

views:

30

answers:

1

I have an mvc application that has been coded to use Windows authentication and runs on an internal intranet. It validates users by matching user.identity.name to what is in the aspnet_users table, this is all good.

However, i have started creating an internet version to run on the web. All the existing default code for account.mvc/LogOn etc is still in place in the app - with associated controller code etc. So far i have taken the following steps:

1) Firstly I went into IIS and switchen off windows authentication 2) Then I altered the section on my web.con fig from:

<authentication mode="Windows"></authentication>

to:

<authentication mode="Forms">
  <forms loginUrl="~/Account.mvc/LogOn" timeout="2880"/>
</authentication>

Then I tried running the application and navigated to http://localhost/LMS/account.mvc/logon but i get:

HTTP 401.2 - Unauthorized: Logon failed due to server configuration Internet Information Services

I then went into my event logs for the day but all it gives me is what i already know, i.e. its a 401 error

Does anyone know which other steps i need to take to make this security change so that i can hit these account view pages?

Many thanks in advance

John

+1  A: 

Check if Basic authentication is enabled for the webapp in IIS. Also, use Fiddler to check if the 401 response contains WWW-Authenticate header. If there's one, IIS is trying to negotiate a different authentication method.

For more info and things to look at - TechNet's 401.1 and 401.2-Authentication Problems

Franci Penov
Thank - you! Now i'm getting somewhere. I enabled basic authentication and now the redirection to the LogOn URL is working but I get a POP-UP connect to dialogue. Do you know how I can stop this from popping up so that the webpage displays asking for the login and password.THANKS! J
John
I would assume you have an XP or Win2K3 machine with no Internet connection configured and the page is referring your browser to an external image or js file. Run Fiddler and check the logs to see what request triggers the dialog.
Franci Penov
I ran fiddler and i get the following: I think it must be a web.config setting or IIS i need to changeNo Proxy-Authorization Header is present.No Authorization Header is present.Any ideas?
John
Ahh, I have now changed the IIS settings, they are now set correctly in that i no longer get the pop-up. The app now redirects to the login page when i hit the home url, this is good. Although, the login URL comes back with a blank webpage, if i view the source i get:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD><BODY></BODY></HTML>I'm running Fiddler 2, do you know where should i look in the results? Thanks for the help.J
John
On the left side should the list of all requests exchanged between the browser and the server (and possibly requests from other processes as well). Look for the request to your login page URL. Double clicking on it will populate the right side with the actual request as sent by the browser on the top and the response as returned by the server on the bottom.
Franci Penov
I get :No Proxy-Authorization Header is present.No Authorization Header is present.my web.config extract is: <authentication mode="Forms"> <forms loginUrl="~/Account.mvc/LogOn" timeout="2880" /> </authentication> <identity impersonate="true"/> Its just serving up a blank page, could i be missing something from the web.config?I have anonymous access on, basic authentication off and integrated windows auth off.
John
also i get this from fiddler under the raw section :HTTP/1.1 401 UnauthorizedServer: Microsoft-IIS/5.1Date: Fri, 12 Mar 2010 11:16:08 GMTX-Powered-By: ASP.NETX-AspNet-Version: 2.0.50727X-AspNetMvc-Version: 1.0Cache-Control: privateContent-Length: 0
John
Also I should say, I have an XP Pro machine running IIS and Visual Studio 2008. I have a working web connection but i'm running website and database locally at the moment
John
turn on basic authentication. turn off impersonation in web.config, or check if the IUSR_machinename account has file permissions to your web app folder. If you turn impersonation off, make sure NerworkService account has file permissions.
Franci Penov
Hi, I have tried all combinations and i think that it must be "IUSR_machinename account has file permissions to your web app folder" that you mention. I am using XP pro so i went to the web app folder and enabled sharing. It does not seem to let me give users permission, is this because its win xp and not server? I've set the account used for anonymous access in the IIS settings with password and still i get blank webpage and it cannot authenticate. At the end of my tether, anything else you can think of? Really appreciate the assistance, cheers, J
John
Right-click on the folder -> Properties -> Security -> Edit... -> Add... and add that account with read and execute properties.
Franci Penov
Thanks, but if i go properties i get 5 tabs: General; Sharing; Subversion; Web Sharing and customise. Under sharing there is 'local sharing and security' and 'network sharing and security'. The first only has a checkbox saying 'make this folder private' - this is greyed out. The 2nd I have selected 'share this folder on the network'. I have not checked the 'allow network users to change my files'. In this tab there is no option to add a user.
John