locked
Forcing HTTPS using HttpModule RRS feed

  • Question

  • User-1226486387 posted

    Hi,

    Would it be a good idea to develop an HttpModule to force a site to switch to https if the user type http ?

    so by adding an extra line in web.config (to load the HttpModule), a user typing www.domain.com would be redirected to https://www.domain.com or a user typing www.domain.com/page1.aspx?param=value would be redirected to https://www.domain.com/page1.aspx?param=value

    Thanks

    Wednesday, November 2, 2005 11:10 AM

All replies

  • User-1226486387 posted
    Any input on this ?
    Friday, November 11, 2005 4:48 PM
  • User-672514680 posted
    I've written, and published exactly what you're asking for in one of my knowledge base articles.

    I tried to past eh code here, but it's not happy in the forums, so you'll hav eto jump out to my site to see it.

    http://scottcate.mykb.com/article_d2244.aspx

    Saturday, November 12, 2005 12:37 AM
  • User-1226486387 posted
    Thanks a lot for the link!

    That is definately the kind of thing I was looking for !
    Wednesday, November 16, 2005 4:52 PM
  • User-672514680 posted
    Your welcome, and enjoy!

    I'll use this thread for support and feedback if you have any.
    Wednesday, November 16, 2005 11:06 PM
  • User-2077437193 posted
    You might also find this blog entry of mine helpful: Requiring HTTPS for Certain ASP.NET Pages. I talk about how this can be done in both IIS and through an ASP.NET page, with info on doing it in an HTTP Module.

    The way I've done this in past projects is not with an HTTP Module, but with a base class that all ASP.NET pages derive from. Both approaches - the base class way vs. HTTP Module - have their pros and cons.

    (The HTTP Module is the "Best Practices" approach, IMHO, but the base class approach is easier to setup/configure, easier to deploy a project, etc.)

    hth

    Wednesday, November 16, 2005 11:57 PM
  • User-1226486387 posted

    I would have thought that an HttpModule would be easier to setup/configure as you only have to copy the dll into the bin folder and add a few line to web.config ..

    no need to recompile or anything..

     

    Thursday, November 17, 2005 10:49 AM
  • User-672514680 posted

    I guess it depends on the time frame that you decide you need this ability.

    Afterwards, or if things change often (or even not often, but just have the probability to change), then I'd lean towards the HttpModule as well.

    Thursday, November 17, 2005 2:18 PM
  • User-2077437193 posted

    I would have thought that an HttpModule would be easier to setup/configure as you only have to copy the dll into the bin folder and add a few line to web.config ..

    no need to recompile or anything..



    The module would be easier after the fact.  But during development, setting up, testing, configuring, etc., using the module is more of a pain than just using the base class, IMO. (As I said, the Module approach is the "best practices" way to go..... the base class is quick 'n' easy...[:)])
    Thursday, November 17, 2005 5:04 PM
  • User1965457893 posted

    I am a little bit lost. I have a httpmodule in place that switches between http and https as needed. It has been working on my test machine. I have been accessing the site using my machines IP address. I have moved my site to the web server and installed a trial certificate with my domain name. I have a DNS server so I have set it up to point my domain name to my web server. I can access the site using my domain name, but it doesn't work when I try and access a page that should be secure. It tells me the page cannot be found. It works if I access the site using the web servers IP address on the web server.

    I am running IIS6.0 and I have two IP addresses. The first is set to port 80 and I tried assigning the second one to port 443, but then my secure pages won't load when I try to access the site from the web server. It does work if the port 443 is set to all unassinged IP addresses.

    Did I miss something in IIS?

    Friday, December 30, 2005 10:25 PM
  • User-1763611275 posted

    Hi

    try this link

    http://www.petri.co.il/configure_ssl_on_your_website_with_iis.htm

    Good Luck

    Tuesday, July 29, 2008 8:43 AM
  • User88744855 posted

    nice post

    Thursday, March 27, 2014 10:17 AM