Running IIS Express with admin privileges
For Visual Studio 2015 and 2012 this solution will work.
- Go to Solution Explorer in Visual Studio, right click the web project and select "Unload Project"
- Next on the same project, right click and select ‘Edit Project File‘
- Find the
<DevelopmentServerPort>0</DevelopmentServerPort><IISUrl>http://localhost:56058/</IISUrl>
xml tags and and remove them. - Reload the project and run.
Images to follow:
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.
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.
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/