Tuesday, March 13, 2012

Switch page to SSL Programatically?

Howdy,

I'm trying to have select pages always be secure and others I don't care.
I'm using

If Request.ServerVariables("SERVER_PORT") = 80 Then

Dim strSecureURL

strSecureURL = "https://"

strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")

strSecureURL = strSecureURL & Request.ServerVariables("URL")

Response.Redirect(strSecureURL)

End If

This works, but is there a better way for .net 2.0?

Thanks,

Merry Christmas

David LozziInstead of testing for the server port variable, test for the HTTPS
variable. It will return ON if it's a secure connection or OFF it is isn't.
This would avoid any issues where the server or ssl certificate is running
on a port other than 80.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"David Lozzi" <dlozzi@.nospam.nospamwrote in message
news:%23VNNyktGHHA.4112@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Howdy,
>
I'm trying to have select pages always be secure and others I don't care.
I'm using
>
If Request.ServerVariables("SERVER_PORT") = 80 Then
>
Dim strSecureURL
>
strSecureURL = "https://"
>
strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
>
strSecureURL = strSecureURL & Request.ServerVariables("URL")
>
Response.Redirect(strSecureURL)
>
End If
>
>
>
This works, but is there a better way for .net 2.0?
>
>
>
Thanks,
>
Merry Christmas
>
David Lozzi
>
>


"David Lozzi" <dlozzi@.nospam.nospamwrote in message
news:%23VNNyktGHHA.4112@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

This works, but is there a better way for .net 2.0?


http://www.codeproject.com/aspnet/W...&select=1697847

0 comments:

Post a Comment