Hi,
I am using the ASP.NET MVC framework and I need to have our site running
under HTTPS.
I have the an HTTP module with the following code running:
public void Init(HttpApplication application)
{
_currentApplication = application;
if (!Continuity2Config.Settings.IsLive)
return;
_preserve = Continuity2Config.Settings.PreserveSSL;
application.BeginRequest += application_BeginRequest;
_log.Error("HTTPS HttpModule has initialised.");
}
protected void application_BeginRequest(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
_currentUri = application.Context.Request.Url;
if ( _preserve && !application.Context.Request.IsSecureConnection)
{
TransferToHttps();
}
}
private void TransferToHttps()
{
_currentApplication.Context.Response.Redirect
(_currentUri.AbsoluteUri.Replace("http://", "https://"), false);
_log.Error("HTTPS Redirect=" + _currentUri.AbsoluteUri.Replace
("http://", "https://"));
}
Basically I am redirecting all requests that come in from HTTP to HTTPS.
My code just does not seem right.
Surely there is a better way of doing this?
Thanks
Paul
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com