3

I enabled SSL in Visual Studio 2015 in order to implement Facebook and Google login locally.

I changed the project URL in the Web tab of the project's properties to https://localhost:44300/ and decorated the controller with the RequireHttps attribute - ref @msdn.

Everything worked fine locally.

I reverted settings to HTTP to test something else and that caused me a problem when I tried to get back to HTTPS.

I found this SO question and tried almost every suggested solution.

Error detail:

Failed to register URL "url" for site "site" application "path". Error description: Access is denied. (0x80070005).

Community
  • 1
  • 1
Goran Sneperger
  • 77
  • 1
  • 1
  • 8
  • You should extract the answer part to an answer and accept it. That's the format of an FAQ if you read other posts. – Lex Li Apr 02 '16 at 01:26

3 Answers3

12

I had to issue this command in DOS to solve the problem in VS 2015:

netsh http add urlacl url=http://{ip_addr}:{port}/ user=everyone

Strangely this was only needed when I moved the project to a different PC. On the original PC I didn't need it.

user2728841
  • 1,333
  • 17
  • 32
  • 2
    Note that *, 127.0.0.1 and localhost are treated as separate... netsh http delete urlacl url=http://*:10001/ netsh http add urlacl url=http://*:10001/ user=everyone netsh http delete urlacl url=http://127.0.0.1:10001/ netsh http add urlacl url=http://127.0.0.1:10001/ user=everyone netsh http delete urlacl url=http://localhost:10001/ netsh http add urlacl url=http://localhost:10001/ user=everyone – Stefan Steiger Apr 05 '17 at 16:49
  • You can also add only your user to ACL with `user=` instead of `everyone`. – onestep.ua Aug 07 '18 at 16:04
  • This worked for me as well. Can anyone elaborate on why this worked? – Aron Boyette Feb 21 '20 at 23:26
2

Turned out this very answer on the same question thread by Cayne led me to the solution.

The port change didn't work because applicationhost.config file, located in .vs folder specific for VS2015, kept bindings combo of old port for Http and Https as a default setting. No matter how many times did I change port to something else while trying with Http (only got clogged with mass of new web site bindings in the config file) as soon as I wanted to switch back to SSL it ended up with the first bindings combo. The port it complained about that can't be registered any more.

Once I deleted that first bindings combo everything was fine.

I hope this will help someone in the future.

Community
  • 1
  • 1
Goran Sneperger
  • 77
  • 1
  • 1
  • 8
0

Go to C:\Users{username}\Documents\IISExpress\config and open the applicationhost.config file.

Search for the <sites> tag in the document. You will see some lines similar to the following.

<site name="WebSite1" id="1" serverAutoStart="true">
    <application path="/">
        <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:8080:localhost" />
    </bindings>
</site>

Replace the line <binding protocol="http" bindingInformation="*:8080:localhost" /> as follows.

<binding protocol="http" bindingInformation="*:{required_port_number}:*" />

I think you can even remove the * marks in bindingInformation.

Then restart IIS Server (remove all IIS server related operations using Task Manager and go to C:\Program Files\IIS Express folder and run iisexpress.exe: you might need to Run as Administrator).

A console will open and if all went well, following lines will be displayed.

Successfully registered URL "http://*:{required_port_number}/" for site "Website1" application "/" ...

Also check in browser whether the required URL works now.

Here's a very useful resource...

Curiosity
  • 1,753
  • 3
  • 25
  • 46
  • FYI Visual Studio will now create an iis express config file in folder .vs/$solution/config, and pass that file as an argument when starting the web site. – Jeremy Lakeman Mar 26 '20 at 01:02