Help with domain page redirect on load in visual basic

Norm Lambert 1 Reputation point
2022-07-23T15:13:50.563+00:00

I want to direct all http: calls to my website to https:

How would I do that in .vb page attached to the .aspx page?

to extend that question even further I have a number of domains that point to my page that I want to change the entire url to https://mysite.com/specificpage.aspx. would that require an if not "https://mysite.com/specificpage.aspx to move to the correct page?

better yet is there code I can put on the masterpage that would do that for all the .aspx files using that masterpage?

Thank you in Advance

Developer technologies | .NET | .NET Runtime
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,861 Reputation points
    2022-07-24T01:08:26.093+00:00

    You will need to add the Strict-Transport-Security (HSTS) header to your website which will force your browser to https instead of http for your site. You can do it in the web.config

    <?xml version="1.0" encoding="utf-8"?>  
    <configuration>  
     <system.web>  
          <!-- Suppress "X-AspNet-Version" header -->  
               <httpRuntime enableVersionHeader="false" />  
        </system.web>    
         <system.webServer>  
        <httpProtocol>  
             <customHeaders>  
              <remove name="X-Powered-By" />  
              <add name="Content-Security-Policy" value="default-src 'self'"/>  
              <add name="Referrer-Policy" value="no-referrer" />  
              <add name="Strict-Transport-Security" value="max-age=31536000"/>  
    

    http://appetere.com/post/security-http-response-headers-for-net-websites-and-apis

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.