Pregunta

This has been asked before but was closed as "Not a real question"

https://stackoverflow.com/questions/7450813/how-to-run-a-site-with-administrative-privileges-in-iis-express-7-5

However I think it is a genuine question as I also need to do this, there are MS documents explaining how to "Run IIS Express without Administrative Privileges" but as this is how it runs by default the need for this article quite frankly baffles me. However I have no idea on how to run it with Admin privileges.

When I try to start my VS2012 website I get the following error message from IIS express: "Cannot start the website because administrative privileges are required to bind to the hostname or port", and links are provided to the MS documents about running it without admin privileges.

What I'm ultimately trying to do is run my dev sites locally as http ://vs2012:nnnnn, this is so I can attach fiddler debugger (due to the bypass of proxies in IE when localhost is used)

This used to work fine, this morning I did a reinstall of windows and have now hit a brick wall!

Does anyone know how to give IIS express admin privileges as indicated in the error message?

¿Fue útil?

Solución 2

I've worked it out.

I switched Visual Studio to running with Administrative Privileges and also found the .exe for IIS Express and set that to always run with administrative privileges. I'm not 100% sure the second was needed but did them both anyway.

I hope this helps some one else who's had this same issue.

EDIT

(19/08/2013)

This only seemed to work in Windows 7, On Windows 8 I eventually just gave up and now use the full blow IIS for all my dev work.

EDIT

(07/06/2018)

@Tarostar (Comment below), got this working on Windows 10 VS2017 and a number of others have got it to work on Windows 8 prior to that using the same method. So possible I was doing something wrong on my Windows 8 box.

Otros consejos

For Visual Studio 2015 and 2012 this solution will work.

  1. Go to Solution Explorer in Visual Studio, right click the web project and select "Unload Project"
  2. Next on the same project, right click and select ‘Edit Project File‘
  3. Find the
    <DevelopmentServerPort>0</DevelopmentServerPort><IISUrl>http://localhost:56058/</IISUrl>
    xml tags and and remove them.
  4. Reload the project and run.

Images to follow:

enter image description here

In my case, the site was working without admin privileges and at some point stopped and worked only with admin.

Port number was higher than 1024 which does not require admin privileges, but Visual Studio 2015 refused to run a site without admin permissions.

I figured out that, it was because of it was added in

netsh http show urlacl

which showed me

Reserved URL            : http://*:15888/
        User: \Everyone
            Listen: Yes
            Delegate: No
            SDDL: D:(A;;GX;;;WD)

So for my case, I have removed it from this list and it worked again. Here is the command for removing:

netsh http delete urlacl http://*:15888/

Although a bit late, and not an answer to the asked question 'how to run with administrative privileges', this might be a solution to the stated problem/error:

Cannot start the website because administrative privileges are required to bind to the hostname or port

As mentioned in running-iis-express-from-the-command-line, the port number used may require these administrative privileges:

you must have Administrator user rights if you want to run IIS Express on ports numbered 1024 or less.

So if you could run on a port number higher than 1024, you might not need administrative privileges at all.

This is not a way to give admin privileges to ISS but a solution to error in the post. I started seeing this error one morning, and solved this by closing Mobile hotspot of my computer. Apparently something about sharing your internet with other devices might result in "Can not start the website because administrative privileges are required to bind to the hostname or port" error.

1)find CSPROJ file. which is inside your project file 2)CSPROJ File is open in notepad(Drag to notepad) 3)search two line (by press Ctrl+F and type frist words eg:)

<DevelopmentServerPort>0</DevelopmentServerPort>
<IISUrl>http://localhost:57680/</IISUrl>

4)DELETE two line. 5)save the CSPROJ file .

I know it might be too late but none of the other work arounds worked for me. So this is what I did. I'm using Web API 2 and the IIS Express didn't fire up from time to time and after I would load the project in a new solution it would work. However, I found a better solution. In the csproj file remove these two nodes under WebProjectProperties and you will be all set.

  • DevelopmentServerVPath
  • IISUrl

this worked for me!

In VS you can right click the project, select Unload Project, and then right click again and select Edit ProjectName.csproj.

Remove the DevelopmentServerPort and IISUrl tags.

After that, you can right click the project and select Reload Project to start working again. Removing the DevelopmentServerPort and IISUrl tags causes VS to re-generate a port number and the project works well after that.

Another thing I did was to open my Documents\IISExpress\Config\applicationHost.config file and delete the old sites, but I’m not sure it was necessary

I solved (worked around) this error by just turning off my VPN.

Not sure why having the vpn running was causing the error, "Cannot start the website because administrative privileges are required to bind to the hostname or port".

One small addition to the method suggested by Morvael - even if you are getting the error after assigning admin privileges to Visual Studio and IISExpress, try restarting the system after that. Worked for me.

You can alter the file at:

%userprofile%\Documents\IISExpress\config\applicationhost.config

Go to this part of the file:

<system.applicationHost>
     <applicationPools>
          <applicationPoolDefaults managedRuntimeLoader="v4.0" >

And add a tag for your application pool specifying the username and password it should run under:

<processModel userName="Uname" password="Pword" />

Chiming in from 2018...I was having this problem on VS 2017 and getting the same error message. To fix it, I changed my Project Url in the project configuration from http://localhost:10243 to http://localhost:10244. Once I confirmed that I wanted to create the virtual directory, I was able to launch my project in the browser. I am NOT running VS in admin mode. Hope this helps!

I ended up solving this issue by right clicking on Visual Studio and clicking 'Run as administrator'.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top