How to enable https in a MVC application
i'm desperate. I try to move my MVC Rest service i developed in C# to the HTTPS protocol. I'm normaly java programer, and i admit, i have some serious trouble with the whole configuration of webapps, specially the web.config file which is a big mistery to me.

So, to my problem. I have a working Rest API running on IIS 7. From what i understood, i have to add a binding to the server for https. So i created my custom certificate, and added the binding. In the IIS manager there where now 2 bindings, the http and the https one.

But, as soon as i did this, i couldn't access the webservice over http, or https. Both gave the same error:

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress 

Googling this error indicated that i need to configure transport security in my web.config file. The problem i have is, that my configuration somehow looks completely different than those in all examples involving the activation of https.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration> 
        <appSettings>
        <add key="webpages:Version" value="1.0.0.0" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
      </appSettings>
        
      <system.web>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
        <authentication mode="None"></authentication>
    
        <httpModules>
          <add name="CustomBasicAuthenticationModule" type="DMAlertRestServer.Server.Authentificator" />
        </httpModules>
    
        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
          </namespaces>
        </pages>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
      </system.serviceModel>
    
      <connectionStrings>
        <add name="DBConnection"
         connectionString="
       Data Source=XXXXX;Initial Catalog=DBAlarmTest;Integrated Security=False;User ID=XXX;Password=XXX;"
         providerName="System.Data.SqlClient"/>
      </connectionStrings>
    </configuration>

Any hint how this can be solved would really be welcome. thank you very much

How to enable https in a MVC application
===

i'm desperate. I try to move my MVC Rest service i developed in C# to the HTTPS protocol. I'm normaly java programer, and i admit, i have some serious trouble with the whole configuration of webapps, specially the web.config file which is a big mistery to me.

So, to my problem. I have a working Rest API running on IIS 7. From what i understood, i have to add a binding to the server for https. So i created my custom certificate, and added the binding. In the IIS manager there where now 2 bindings, the http and the https one.

But, as soon as i did this, i couldn't access the webservice over http, or https. Both gave the same error:

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress 

Googling this error indicated that i need to configure transport security in my web.config file. The problem i have is, that my configuration somehow looks completely different than those in all examples involving the activation of https.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration> 
        <appSettings>
        <add key="webpages:Version" value="1.0.0.0" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
      </appSettings>
        
      <system.web>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
        <authentication mode="None"></authentication>
    
        <httpModules>
          <add name="CustomBasicAuthenticationModule" type="DMAlertRestServer.Server.Authentificator" />
        </httpModules>
    
        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
          </namespaces>
        </pages>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
      </system.serviceModel>
    
      <connectionStrings>
        <add name="DBConnection"
         connectionString="
       Data Source=XXXXX;Initial Catalog=DBAlarmTest;Integrated Security=False;User ID=XXX;Password=XXX;"
         providerName="System.Data.SqlClient"/>
      </connectionStrings>
    </configuration>

Any hint how this can be solved would really be welcome. thank you very much
