Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 723
nazgul Avatar asked Sep 14 '15 06:09

nazgul


Video Answer


2 Answers

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"

like image 185
Jon Brichoux Avatar answered Sep 23 '22 15:09

Jon Brichoux


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.

like image 35
Muhammad Rehan Saeed Avatar answered Sep 26 '22 15:09

Muhammad Rehan Saeed