4 Replies - 482 Views - Last Post: 17 February 2017 - 09:10 AM

#1 Coding in the name of  Icon User is offline

  • D.I.C Regular

Reputation: 67
  • View blog
  • Posts: 291
  • Joined: 07-July 10

Require HTTPS and redirect

Posted 14 February 2017 - 11:27 AM

I'm developing with IIS Express and I want to cause all requests to the website to use HTTPS. I have a trusted self-signed certificate for localhost. It seems to work in Chrome but in Firefox and IE if I make a request to http the browser eventually times out instead of redirecting. Can someone explain what I'm doing wrong? Thanks.

I've put this in the Web.config
    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
        <remove name="X-Frame-Options" />
        <remove name="Strict-Transport-Security"/>
        <add name="X-Frame-Options" value="SAMEORIGIN" />
        <add name="Strict-Transport-Security" value="max-age=16070400" />
      </customHeaders>
    </httpProtocol>


And this for global filters:
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
            filters.Add(new RequireHttpsAttribute());
        }


Is This A Good Question/Topic? 0
  • +

Replies To: Require HTTPS and redirect

#2 Coding in the name of  Icon User is offline

  • D.I.C Regular

Reputation: 67
  • View blog
  • Posts: 291
  • Joined: 07-July 10

Re: Require HTTPS and redirect

Posted 15 February 2017 - 10:34 AM

I added a URL Rewrite rule on the production web server through the GUI as described here (I couldn't figure out how to add it in the Web.config, it gave me a 500.19 error when I added a <rewrite> section, and I can't see changes in my Web.config on the server after adding the rewrite rule through the GUI) and this seems to work in Firefox. In IE the URL doesn't rewrite and for some reason the web server doesn't refuse the HTTP request.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6537
  • View blog
  • Posts: 30,604
  • Joined: 10-May 07

Re: Require HTTPS and redirect

Posted 15 February 2017 - 10:45 AM

** Moved to web servers & hosting **

If this were nginx or Apache, I could help you write a redirect based on protocol. However I have no experience with IIS.
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2325
  • View blog
  • Posts: 9,345
  • Joined: 03-December 12

Re: Require HTTPS and redirect

Posted 15 February 2017 - 12:17 PM

I would check here, Config IIS https redirects.
Was This Post Helpful? 0
  • +
  • -

#5 Coding in the name of  Icon User is offline

  • D.I.C Regular

Reputation: 67
  • View blog
  • Posts: 291
  • Joined: 07-July 10

Re: Require HTTPS and redirect

Posted 17 February 2017 - 09:10 AM

I think the URL rewrite is actually working. Maybe it looked like it wasn't because of cached pages. I just need to find out in which file is the rule actually stored now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1