nazgul
nazgul

Reputation: 539

Enabling SSL for ASP.NET 5 project in Visual Studio 2015 Community RTM

Most tutorials suggest that you can enable SSL for the website by going to properties of the project and then ticking the "Enable SSL" checkbox. However for my ASP.NET 5 projects in Visual Studio 2015 Community (Microsoft Visual Studio Community 2015 Version 14.0.23107.0 D14REL) this option doesn't exist (see the screenshot visual studio properties for asp.net 5 project).

I was able to workaround it by manually adding https protocol binding in applicationhost.config (following pre-RTM instruction in https://github.com/AzureADSamples/WebApp-OpenIdConnect-AspNet5), but I found out that Visual Studio is overwriting this file from time to time, which forces me to do the manual edit over and over again.

When I create a new Web application project, the "Enable SSL" is available only when I use ASP.NET 4.5 templates, but not when I use ASP.NET 5 Preview templates. Is there a way to configure this option for ASP.NET 5 projects in a way that persists?

Upvotes: 6

Views: 10205

Answers (4)

Muhammad Rehan Saeed
Muhammad Rehan Saeed

Reputation: 38537

RTM, RC2 & RC1 Answer

You need to use launchSettings.json in the properties folder of the project. Note the sslPort setting. Note that for RC1 ASPNETCORE_ENVIRONMENT becomes Hosting:Environment.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:1025/",
      "sslPort": 44300
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "web": {
      "commandName": "web",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Beta 8 Answer

You can edit the .xproj file and add the SSLPort element to add it manually but this should really be available to any version of VS and I'd advise you to raise an issue on the ASP.NET Tooling GitHub page:

<PropertyGroup>
    <SchemaVersion>2.0</SchemaVersion>
    <DevelopmentServerPort>1025</DevelopmentServerPort>
    <SSLPort>44300</SSLPort>
</PropertyGroup>

The port number must be a number between 44300 and 44399.

Upvotes: 10

Protector one
Protector one

Reputation: 7331

Change the Project Url in the Web tab of your Project's settings to:

https://localhost:44300/

The port number can be changed, but it needs to be in the 44300-44399 range.

Upvotes: 5

Jon Brichoux
Jon Brichoux

Reputation: 111

I ran into the same problem as you. Problem is, there are two "Properties" for a project. If you right click on the project node in Solution Explorer and choose Properties, you will see the properties window that you show above, and no, it doesn't have "SSL Enabled" as an option. However, with the project node in Solution Explorer selected, if you view "Properties Window" (an option in View menu) then you will see the (normally docked) properties window which has this option. By the way, the difference between the two windows in View menu is "Properties Window" (the one you want) and "Property Pages" (the one you show above, not the right one). However once you get to Properties Window, although you'll be able to enable SSL, the port will be read-only. After much reading on that topic, I think all you have to do is edit the bindings in the applicationhost.config file that automatically gets created:

path from solution: ./.vs/config/applicationhost.config

xpath within file: /configuration/system.applicationHost/sites/site[@name="{your site name here}"]/bindings/binding[@protocol="https"]/@bindingInformation="*:{port}:localhost"

Upvotes: 11

ChrisP
ChrisP

Reputation: 10116

Check out this post

http://weblogs.asp.net/scottgu/released-today-visual-studio-2015-asp-net-4-6-asp-net-5-ef-7-previews

and read the section on SSL.

Upvotes: -1

Related Questions