I came up with a necessity to work with my asp.net mvc site from a remote pc while developing. So, I configured it to use IIS Express.
At first, a problem raised wit
try placing a web.config
file in you Content
folder. and put the following code in it.
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>
It may be due to the error in resolving the root path where Css is located. You can try with Url helpers to resolve this issue.
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Site.css")" media="screen" />
In Asp.net development server(In visual studio environments) <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
will work fine.. but while hosting in IIS, root path cannot be resolved using a relative path. With the help of Url helpers we can resolve this issue. Using Firebug you can see the load error of resources if any.
Edit:
In the web.config under the <system.web>
section modify as follows.
<system.web>
<identity impersonate="true" userName="ServerName\Administrator" password="password"/>
</system.web>
Give the proper values for username and password. You can try giving folder permission to the IIS user groups(IUSR
,IIS_IUSR
) to the folder where application is hosted.(Right click the hosted folder -> Properties
under the Security
tab, you can find the user groups and can give permissions)
The problem was connected with netsh and binding configuration in ISS Express. At first I setup it through my ip, and it resulted in confusing errors.
While searching for anything in the web I ran across Setting up IIS Express. All the same there, but it's suggested using pc name in netsh and iis applicationhost.config.
So, I added
netsh http add urlacl url=http://MyPCName:MyPort/ user=everyone
and
<binding protocol="http" bindingInformation="*:MyPort:MyPCName" />
and a miracle!! It worked.
As for the IE, I had to turn off the "Use Windows authorization" flag to make it work. Many thanks to Internet Explorer - Enable Integrated Windows Authentication. But nevertheless IE still asks for login and password, if an ip is used in url. If pc name is used it works silently.
Firefox either asks for login and password (and works if one enters valid credentials) or you should apply How To: Firefox and Integrated Windows Authentication (mentioned in my question) and then it works silently both with ip and pc name.
Hope this helps someone else.
EDIT
One remark: I had to launch VS2010 with administrtor permissions. If not, I still get HTTP 500 error based on the bad impersonation error. So, it looks like IIS Express, launched by VS2010 without administrator permissions under Windows 7, won't be able to work correctly.
As far as I understood, the clue is to give the appropriate permissions to IIS_IUSRS. But until that it's easier to launch VS 2010 with administrator privilages.