domster
domster

Reputation: 566

ASP.NET WebSite SSL with Visual Studio 2015

I'm currently working on a ASP.NET WebSite Security Project in School.

My objective is to start up my website with the URL of HTTPS, securing it with SSL.

I have been researching high and low over the net for guidance on how to properly enable SSL.

I'm using VISUAL STUDIO 2015 , and i have seen that the project properties can automatically enable SSL and then create a self-signed certificate.

I have actually gotten my website to be running at a URL - https://localhost:443/Example.aspx

It worked.. Then i played around with it here and there and i realised it requires VS 2015 to be run as administrator for it to work..

But i'm not sure if i'm setting up the SSL properly..

My queries are actually..

  1. How do i properly set up SSL for my project using self signed certificate, with makecert to create a localhost certificate and assigning port 443 via IIS (Default WebSite bindings) ?
  2. How do i set the start up URL to be HTTPS?
  3. Do i have to enabled SSL for my project?

For query 2, i have actually researched, and many stated that, right clicking on my project then Property Pages -> Start Options -> Configure from there.

But this is actually what i get..

I tried playing around with the Start URL but it doesn't work at all.. I think maybe IIS is preventing it from working.. And i know there must be of something that i'm doing wrongly.. And i compared the Property Pages window and it's different from what i see from others..

Query 3,

enter image description here

These are the codes i used for my Web.Config file.

<system.webServer>
  <!--<modules runAllManagedModulesForAllRequests="true" >
    <remove name="UrlRoutingModule"/>
  </modules>-->
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>  

Inside my applicationhost.config file

<site name="FinancialHub" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Users\Dom\Documents\Visual Studio 2015\WebSites\FinancialHub" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:6868:localhost" />
                <binding protocol="https" bindingInformation="*:443:localhost" />
            </bindings>
        </site>

Might have more queries along the way.. All i can think of now is the foundation and fundamentals which i have done wrongly i presume..

Everything is messy.. I sincerely apologise.. I tried my best to search for what i can but to no avail..

Really appreciate any procedural help..

Upvotes: 0

Views: 659

Answers (1)

hambone_the_great
hambone_the_great

Reputation: 15

In Web.Config:

<system.webServer>    
  <rewrite>
    <rules>
      <rule name="Redirect to https" enabled="True">
         <match url="(.*)"/>
         <conditions>
            <add input="{HTTPS}" pattern="Off"/>
         </conditions>
         <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
       </rule>                   
     </rules>
    </rewrite>    
</system.webServer> 

Upvotes: 0

Related Questions