Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Switching Between HTTP and HTTPS

Reply
Thread Tools

Switching Between HTTP and HTTPS

 
 
Kenneth Keeley
Guest
Posts: n/a
 
      10-14-2003
Hi
I wish to have a web site that has most of the pages as normal HTTP pages
but has some areas that use HTTPS. I want to have it that if a user selects
a link to a HTTPS page that they go there an there Session Information is
kept. I also wish to have the pages switch automatically to HTTPS if a
visitor types the URL without the HTTPS. So my questions are:
1) How to redirect to a Secure Page without losing Session Info?
2) How to test if page is accessed by HTTPS, and if not switch to HTTPS
quickly?

I think something like this code is what I want but how do I do it.

<%
if not "HTTPS" then
response.redirect(https://mysite.com/securepage.asp)
end if
%>

Thanks for the help.
Kenneth Keeley


 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      10-14-2003

"Kenneth Keeley" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> So my questions are:
> 1) How to redirect to a Secure Page without losing Session Info?


This is not possible. Sessions cannot be maintained across different
protocols. You'll have to store the info server-side in a database, for
example.

> 2) How to test if page is accessed by HTTPS, and if not switch to

HTTPS
> quickly?


Here's an example:
http://www.aspfaq.com/2321

You'd probably also want to grab the querystring, should it exist. Maybe do
it like this instead (illustrative example):

<%
Dim sRedirect, sDomain, sPath, sQString
If UCase(Request.ServerVariables("HTTPS") = "OFF" Then
sDomain = Request.ServerVariables("SERVER_NAME")
sPath = Request.ServerVariables("SCRIPT_NAME")
sQString = Request.Querystring
sRedirect = "https://" & sDomain & sPath
If Len(sQString) > 0 Then sRedirect = sRedirect & "?" & sQString
Response.Redirect sRedirect
End If
%>


Ray at home


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
switching between https and http Hemant ASP .Net 0 09-16-2009 02:07 PM
Best practises for switching between https and http pages in .NET Mike Tallman ASP .Net Security 0 11-22-2005 06:59 PM
Switching between http and https CS ASP .Net Security 1 04-29-2005 04:51 AM
Switching between http and https popping up a login box Tony Wright ASP .Net Security 0 05-28-2004 12:24 AM
Re: Switching Between HTTP and HTTPS Jerry III ASP .Net 0 10-15-2003 07:33 AM



Advertisments