Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 48173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:14:18+00:00 2026-05-10T16:14:18+00:00

About 6 months ago I rolled out a site where every request needed to

  • 0

About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time I could find to ensure that every request to a page was over https was to check it in the page load event. If the request was not over http I would response.redirect(‘https://example.com‘)

Is there a better way — ideally some setting in the web.config?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:14:19+00:00Added an answer on May 10, 2026 at 4:14 pm

    Please use HSTS (HTTP Strict Transport Security)

    from http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx

    <?xml version='1.0' encoding='UTF-8'?> <configuration>     <system.webServer>         <rewrite>             <rules>                 <rule name='HTTP to HTTPS redirect' stopProcessing='true'>                     <match url='(.*)' />                     <conditions>                         <add input='{HTTPS}' pattern='off' ignoreCase='true' />                     </conditions>                     <action type='Redirect' url='https://{HTTP_HOST}/{R:1}'                         redirectType='Permanent' />                 </rule>             </rules>             <outboundRules>                 <rule name='Add Strict-Transport-Security when HTTPS' enabled='true'>                     <match serverVariable='RESPONSE_Strict_Transport_Security'                         pattern='.*' />                     <conditions>                         <add input='{HTTPS}' pattern='on' ignoreCase='true' />                     </conditions>                     <action type='Rewrite' value='max-age=31536000' />                 </rule>             </outboundRules>         </rewrite>     </system.webServer> </configuration> 

    Original Answer (replaced with the above on 4 December 2015)

    basically

    protected void Application_BeginRequest(Object sender, EventArgs e) {    if (HttpContext.Current.Request.IsSecureConnection.Equals(false) && HttpContext.Current.Request.IsLocal.Equals(false))    {     Response.Redirect('https://' + Request.ServerVariables['HTTP_HOST'] +   HttpContext.Current.Request.RawUrl);    } } 

    that would go in the global.asax.cs (or global.asax.vb)

    i dont know of a way to specify it in the web.config

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I built a site about 6 months ago now and designed a menu with
We migrated from VSS to TFS about 6 months ago. Our way of storing
We branched off the main project about 6 months ago. In that time the
I've only started learning Java about 3 months ago and this is my first
A few months ago I read about a technique so that if there parameters
About 2 months ago I overtook building proccess in current company. Even though I
I learned HTML and CSS about 8 months ago, and recently, about 2 months
I had many problems installing Team Foundation Server 2005 (Workgroup) about six months ago
I've tried to deal with this before, about 8 months ago, I didn't find
I started learning Rails only a few days ago, but in the mean time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.