This isn't so much an Umbraco question, but I thought I would throw it out there in case anyone has an idea.
With IIS 7, if a user tries to load my site via https and I don't have an SSL cert (don't need one yet), they get an ugly browser error. How can I either redirect them to the http version of the page or present a custom (looks like my site) error message?
It does not appear that an actual http response code is being sent and since no page is loaded, any code in my Page_Load event is ignored.
Oh, this is the case? You haven't create certificate in your iis. You can create certificate by choosing top root of your iis(possibility your computer name) and then you will find Server Certificates in right pane. From there you can create certificate and while binding with https type you just choose frienldy name of your certificate in ssl certificate
Ah, see that's where we have the confusion. On this server/site we don't have an SSL cert and don't need one until perhaps next year. No one can view the site via https, but when they try they get denied with an ugly browser error. I was hoping to change that, in case there happen to be links or bookmarks out there to https pages or similar.
You can also add an "unverified" cert to your IIS -- ie a cert that is self-generated and isn't actually backed up by a signing authority (like geotrust, etc), and then swap it out when you get your "real" cert
I've done something similar to this with a custom HttpModule, but the other way around (forcing https). In the HttpModule, bind a new EventHandler on context.PreRequestHandlerExecute. For your purposes, I think that function would look something like:
void OnPreRequestHandlerExecute(object sender, EventArgs e) { if (application.Request.Url.Scheme == "https") {
// Rebuild the requested Uri with "http" as the scheme
var uriBuilder = new UriBuilder(new Uri(application.Request.Url,application.Request.RawUrl));
uriBuilder.Scheme = "http";
uriBuilder.Host = requestHost; // You might have to use uriBuilder.Uri.GetComponents() to build this redirect in the right way
application.Response.Redirect(uriBuilder.ToString()); } }
Anyway you do it, you will need to create a certificate under IIS. You can do a self-signed one just to set up the binding, and the above code should prevent IIS from ever trying to serve that certificate. At least, I'm pretty sure that's how it will work...
Force https requests to http?
This isn't so much an Umbraco question, but I thought I would throw it out there in case anyone has an idea.
With IIS 7, if a user tries to load my site via https and I don't have an SSL cert (don't need one yet), they get an ugly browser error. How can I either redirect them to the http version of the page or present a custom (looks like my site) error message?
It does not appear that an actual http response code is being sent and since no page is loaded, any code in my Page_Load event is ignored.
Hi Connie,
Faced same problem before. I did solved it by assigning domain name begining with both https and http and placed below code in template's head section
Thanks
Pnima
Hi Pasang,
How were you able to assign the https domain? If I try and add an https binding in IIS, it won't let me do anything if I don't add a cert.
For my website I just right click to get edit binding and from there I added domain with type https.
Pnima
Not to be a pain, but this is what I see... the OK is greyed out and I cannot add the binding.
Oh, this is the case? You haven't create certificate in your iis. You can create certificate by choosing top root of your iis(possibility your computer name) and then you will find Server Certificates in right pane. From there you can create certificate and while binding with https type you just choose frienldy name of your certificate in ssl certificate
Thanks
Pnima
Hi
Here I found one good article about creating server certificates http://www.sslshopper.com/article-installing-an-ssl-certificate-in-windows-server-2008-iis-7.0.html
Thanks
Pnima
Ah, see that's where we have the confusion. On this server/site we don't have an SSL cert and don't need one until perhaps next year. No one can view the site via https, but when they try they get denied with an ugly browser error. I was hoping to change that, in case there happen to be links or bookmarks out there to https pages or similar.
Anyone?
You can try adding this to your urlrewriting.config file
<add name="KickToHttps" virtualUrl="^http\://www.yourdomain.com/" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="https://www.yourdomain.com/" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
<add name="KickToHttps" virtualUrl="^http\://www.yourdomain.com/(.*)" destinationUrl=https://www.yourdomain.com/$1 redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
Sorry wrong way around (post editing does not seem to be working)
You can also add an "unverified" cert to your IIS -- ie a cert that is self-generated and isn't actually backed up by a signing authority (like geotrust, etc), and then swap it out when you get your "real" cert
We have no plans to add a cert to this server for several months.
I don't think the URL rewrite will work if the request never makes it to the site in order to be processed.
I've done something similar to this with a custom HttpModule, but the other way around (forcing https). In the HttpModule, bind a new EventHandler on context.PreRequestHandlerExecute. For your purposes, I think that function would look something like:
Anyway you do it, you will need to create a certificate under IIS. You can do a self-signed one just to set up the binding, and the above code should prevent IIS from ever trying to serve that certificate. At least, I'm pretty sure that's how it will work...
Scott Gu on Enabling Self-Signed Certs
http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx
is working on a reply...