16

I feel like I must be missing something easy, but does anyone know how to enable SSL for IIS Express when using an ASPNET5 web project? The Project Properties Debug screen only shows a port, not a URL ("classic" web projects still allow you to specific https in the url)

NPNelson
  • 2,940
  • 2
  • 16
  • 27
  • Possible duplicate of [Enabling SSL for ASP.NET 5 project in Visual Studio 2015 Community RTM](http://stackoverflow.com/questions/32558395/enabling-ssl-for-asp-net-5-project-in-visual-studio-2015-community-rtm) – Rafael Miceli Mar 15 '16 at 22:03
  • Any idea how to do this in Visual Studio 2017 RC? I have an empty ASP.Net Core MVC project, but there is no Development Server Properties section or Web Server Properties in the Project Properties -> Debug tab. – Ashley Bye Dec 11 '16 at 00:21

5 Answers5

14

Edit your applicationhost.config in [SOLUTION_DIR]\.vs\config

for exemple in the sites section :

<site name="YOUR SITE NAME" id="1">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="YOUR SITE PATH" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:80:localhost" />
      <binding protocol="https" bindingInformation="*:44300:localhost" />
    </bindings>
</site>
Julian
  • 20,008
  • 17
  • 77
  • 108
agua from mars
  • 16,428
  • 4
  • 61
  • 70
  • 4
    I hope this isn't the only way cause this is terrible. – Sailing Judo Jul 15 '15 at 19:59
  • @SailingJudo I don't get why u think it's terrible. – agua from mars Jul 16 '15 at 07:39
  • 12
    VS2015 RTM seems to be locating config in $[solutionDir]\.vs\config\applicationhost.config – fiat Jul 23 '15 at 03:43
  • 1
    In RC2 you can edit the launchSettings.json file in /Properties. – Christopher Feb 12 '16 at 17:07
  • Which binding do I edit? I have multiple bindings in my applicationhost.config. One under and one under . It is a C# MVC Web App. See how I created it here: http://work.haufegroup.io/haufe-adfs-identity-for-aspnet-login/ – Tom McDonald Jan 04 '18 at 16:01
  • @TomMcDonald the one corresponding to your site name. – agua from mars Jan 04 '18 at 16:13
  • @ agua I suppose that means the 'website' binding. – Tom McDonald Jan 04 '18 at 19:46
  • To see the .vs folder I had to edit the properties of the file viewer to show hidden system files. Once I could edit it I had to edit all https bindings as there were multiple https bindings. This didn't work, but at least I started getting a new error message. I now get..."IDX10214: Audience validation failed. Audiences: 'https://localhost:44300/'. Did not match: validationParameters.ValidAudience: 'https://localhost:44300' or validationParameters.ValidAudience' – Tom McDonald Jan 09 '18 at 22:27
13

You do this in a vNEXT project almost exactly the same as prior projects. Microsoft just moved the settings to the debug tab of the project properties.

  1. Open the properties of the project
  2. Select the debug tab on the left
  3. Tic the checkbox for Enable SSL

enter image description here

If yout don't have the above option

Click the project root node in the explorer window, press F4 and adjust the following:

enter image description here

Community
  • 1
  • 1
Paul
  • 12,392
  • 4
  • 48
  • 58
  • 3
    This worked for me and is a MUCH BETTER solution than the accepted answer of editing the applicationhost.config. IMO the accepted answer should be changed to this one. – RonC Aug 24 '16 at 14:05
  • Debug tab is missing in my Visual Studio 2015 and 2017...perhaps it was removed? – Tom McDonald Jan 04 '18 at 15:58
  • when you incorperated other answers from this question into your own, I think it would have been best practice to change your post to community wiki – Kevin Jan 28 '20 at 12:44
12

This can be done simply if you click on the project in the Solution Explorer the open the Properties and set the SSL Enabled to True.

Enable SSL VS2015

Kos
  • 567
  • 4
  • 15
  • Visual Studio 2015 shows this to be the answer for an MVC project. Just select the project and select SSL enabled to be true in the properties pane. – EeKay Dec 06 '16 at 09:35
  • What is I use IIS instead of IIS express? There is no such setting, only if I choose IIS Express. – Vlado Pandžić Dec 08 '16 at 14:26
  • 3
    You need to open a properties window instead of property page. You can open the properites window in View > properties window (F4) – Kuroro Mar 16 '17 at 04:54
8

Click on the project and press F4, it will show the same properties list as previous visual studio versions where you can set SSL to true.

It will look like this in VS 2015

Example

hardkoded
  • 18,915
  • 3
  • 52
  • 64
Kevin
  • 2,258
  • 1
  • 32
  • 40
  • this works, but if you need to edit the grayed out fields (ssl url, url) you'll need to see tom mcdonald's answer above. – Tom McDonald Oct 16 '18 at 15:05
1

None of the solutions above apply if you are doing .Net 4.5 MVC project with "on premise", aka, ADFS authentication. If so, you won't see a 'debug' tab (see image below). You won't see an "Enable SSL" toggle box. Everything is done automatically by the IDE as long as you select a port in the acceptable range. I used the port 44300 and VS configured the /.vs/config/applicationhost.config file automatically (see below). I think VS might automatically setup SSL with the other authentication types (OAuth, etc.), but I haven't tested it.

ADFS SSL Visual Studio

Tom McDonald
  • 1,532
  • 2
  • 18
  • 37
  • Note, I did have to manually set the project URL (shown in the image) to port 44300. Even though I'd specified the URI as {httpss://localhhost:44300} in the 'on premise' authentication setup, VS didn't carry that through to the Project Url. That's probably by design as URI <> URL. – Tom McDonald Jan 15 '18 at 15:49
  • update: I was able to find the "SSL Enabled" property window in VS 2017. It appears to be deprecated, but it still works. Select the project in solution explorer and then press F4. Changes there will update the config file as described above. For more information go to http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/ – Tom McDonald Jan 17 '18 at 20:03
  • confirmed the F4 menu does the same thing as directly editing the [project root]/.vs/config/applicationhost.config file. See the system.webserver.security.authentication node for authentication settings. I wanted to turn SSL off for IIS express so I set anonymousAuthentication = true and windowsAuthentication = false – Tom McDonald Jan 18 '18 at 14:15
  • Some fields are grayed out for F4. To edit them you must directly edit the config file using a text editor. – Tom McDonald Oct 16 '18 at 15:06