Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > http to https redirect

Reply
Thread Tools

http to https redirect

 
 
Axel
Guest
Posts: n/a
 
      03-28-2009
Hi

This is a standard asp question, (old site done with standard asp and
vb) I did not find an English speaking "plain asp" group;

I am trying to redirect on some (login) pages from https to http by
using Response.Redirect but it seems to always end up on https pages.
The other way around (http to https) works fine. What could cause such a
behavior? Maybe some global switch in global.asa? Or cookies set by the
secure page? Its really weird.

I am considering doing the redirect client side but I don't want the
whole page to load and then to the redirect as its slooow. OTOH I am
scared of cutting the page short server site in case the client redirect
method fails (e.g. due to ignoring javascript or meta headers). Is there
a sure fire way to redirect to non-secure after successful login?

thanks in advance
Axel
 
Reply With Quote
 
 
 
 
Toni
Guest
Posts: n/a
 
      03-29-2009
"Axel" wrote...
> Hi
>
> This is a standard asp question, (old site done with standard asp and vb) I did not
> find an English speaking "plain asp" group;
>
> I am trying to redirect on some (login) pages from https to http by using
> Response.Redirect but it seems to always end up on https pages. The other way around
> (http to https) works fine. What could cause such a behavior? Maybe some global switch
> in global.asa? Or cookies set by the secure page? Its really weird.
>
> I am considering doing the redirect client side but I don't want the whole page to
> load and then to the redirect as its slooow. OTOH I am scared of cutting the page
> short server site in case the client redirect method fails (e.g. due to ignoring
> javascript or meta headers). Is there a sure fire way to redirect to non-secure after
> successful login?
>
> thanks in advance
> Axel


Instead of response.redirect, use Response.AddHeader
<%
' strURL = URL you want to redirect to
strURL = http://www.UrlRedirect.com
Response.AddHeader ("Location", strURL)
Response.End
' rest of code goes here
%>

I've found that Response.AddHeader is much nicer and has a more predictable behavior
than response.redirect.
Although most would say it's not needed, I always place Response.End after any redirect
in case the redirect fails for any reason whatsoever (I'm just paranoid that way).

You might need the parenthesis around it if you are doing ASP.NET, they are not needed
in Classical ASP.







 
Reply With Quote
 
 
 
 
George
Guest
Posts: n/a
 
      03-30-2009
you code to set the return code to 302 or 301 for it to work
Response.StatusCode = 302

George.


"Toni" <> wrote in message
news:...
> "Axel" wrote...
>> Hi
>>
>> This is a standard asp question, (old site done with standard asp and vb)
>> I did not find an English speaking "plain asp" group;
>>
>> I am trying to redirect on some (login) pages from https to http by using
>> Response.Redirect but it seems to always end up on https pages. The other
>> way around (http to https) works fine. What could cause such a behavior?
>> Maybe some global switch in global.asa? Or cookies set by the secure
>> page? Its really weird.
>>
>> I am considering doing the redirect client side but I don't want the
>> whole page to load and then to the redirect as its slooow. OTOH I am
>> scared of cutting the page short server site in case the client redirect
>> method fails (e.g. due to ignoring javascript or meta headers). Is there
>> a sure fire way to redirect to non-secure after successful login?
>>
>> thanks in advance
>> Axel

>
> Instead of response.redirect, use Response.AddHeader
> <%
> ' strURL = URL you want to redirect to
> strURL = http://www.UrlRedirect.com
> Response.AddHeader ("Location", strURL)
> Response.End
> ' rest of code goes here
> %>
>
> I've found that Response.AddHeader is much nicer and has a more
> predictable behavior than response.redirect.
> Although most would say it's not needed, I always place Response.End after
> any redirect in case the redirect fails for any reason whatsoever (I'm
> just paranoid that way).
>
> You might need the parenthesis around it if you are doing ASP.NET, they
> are not needed in Classical ASP.
>
>
>
>
>
>
>


 
Reply With Quote
 
Axel
Guest
Posts: n/a
 
      04-18-2009
Hi - I am still struggling can not make a server side redirect happen
from https to http.

I tried George's and also Toni's suggestion (see below). I always end up
on a https page again. Could it be something that the ISP enforces? In
the browser, I can follow links from https to http pages but the (server
side) redirect from https to http after successful login just simply
does not work for me - always stays in https!

After reading
http://www.4guysfromrolla.com/aspfaq...Q.asp?FAQID=72 (ADPFAQs.com)
and
http://www.somacon.com/p145.php (Permanent Redirect with HTTP 301)

Here is my final code - I also made sure not have ANY output before I
call the page. However some session variables are written (these are
needed to identify the user once he is logged on)

Function redirectNoSSL(sUrl)
Dim sNewURL
sNewURL = stripSSL(sUrl)
If Response.Buffer=True then
Response.Clear
Response.Buffer=False
End If

'Call Response.Redirect(sNewURL)
' instead of redirect!

Response.Status = "301 Moved Permanently"
Call Response.AddHeader ("Location", sNewURL)
End Function

(stripSSL works fine it just rewrites the (complete) passedf URL with
http: instead of https

any other suggestions.


George wrote:
> you code to set the return code to 302 or 301 for it to work
> Response.StatusCode = 302
>
> George.
>
>
> "Toni" <> wrote in message
> news:...
>> "Axel" wrote...
>>> Hi
>>>
>>> This is a standard asp question, (old site done with standard asp and
>>> vb) I did not find an English speaking "plain asp" group;
>>>
>>> I am trying to redirect on some (login) pages from https to http by
>>> using Response.Redirect but it seems to always end up on https pages.
>>> The other way around (http to https) works fine. What could cause
>>> such a behavior? Maybe some global switch in global.asa? Or cookies
>>> set by the secure page? Its really weird.
>>>
>>> I am considering doing the redirect client side but I don't want the
>>> whole page to load and then to the redirect as its slooow. OTOH I am
>>> scared of cutting the page short server site in case the client
>>> redirect method fails (e.g. due to ignoring javascript or meta
>>> headers). Is there a sure fire way to redirect to non-secure after
>>> successful login?
>>>
>>> thanks in advance
>>> Axel

>>
>> Instead of response.redirect, use Response.AddHeader
>> <%
>> ' strURL = URL you want to redirect to
>> strURL = http://www.UrlRedirect.com
>> Response.AddHeader ("Location", strURL)
>> Response.End
>> ' rest of code goes here
>> %>
>>
>> I've found that Response.AddHeader is much nicer and has a more
>> predictable behavior than response.redirect.
>> Although most would say it's not needed, I always place Response.End
>> after any redirect in case the redirect fails for any reason
>> whatsoever (I'm just paranoid that way).
>>
>> You might need the parenthesis around it if you are doing ASP.NET,
>> they are not needed in Classical ASP.
>>
>>
>>
>>
>>
>>
>>

>

 
Reply With Quote
 
Axel
Guest
Posts: n/a
 
      04-21-2009
>> I am still struggling can not make a server side redirect happen from
>> https to http.

>
> And you're still in the wrong newsgroup...
>
> please post ASP Classic questions to:
> microsoft.public.inetserver.asp.general

thanks Mark, I will take it there again (I was just encouraged by the
answers on this group; there was lot less feedback on there, but I guess
its a difficult enough question which might be environment dependant)
 
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
redirect from https to http w/o security warning =?Utf-8?B?RGFiYmxlcg==?= ASP .Net 6 09-23-2009 10:06 AM
server side redirect https => https NOT working Axel ASP General 8 04-27-2009 02:02 AM
open-uri and HTTPS, or net/https with a redirect jotto Ruby 4 10-02-2006 07:26 AM
Login in HTTPS and redirect to HTTP using Forms Authentication Alfredo Barrientos ASP .Net 0 08-31-2005 09:31 PM
Jetty and http to https redirect Forrest Samuels Java 1 12-05-2004 12:17 AM



Advertisments