Switching to ssl and back

  • Thread starter Thread starter MattB
  • Start date Start date
M

MattB

I've seen some different suggestions about this, and I'm wondering if
there's a common way to do it. I have an app I'll be distributing, so we
can't hardcode a absolute URL in it. I've seen an add-in for doing this, but
I'd like to have this all be our code if possible. Is there a consensus on
the best or most common way to switch to/from ssl?
I'm thinking if there's a way I can get the absolute URL for something I
could then just have a shared function call to change the protocol in that
URL. Is there a way to retrieve the absolute URL from a relative reference
in VB.net? For example, if I could do something like GetAbsURL(myPage.aspx)
and have it return http://www.mydomain.com/myDir/myPage.aspx that would be
perfect. Anything like that available? TIA!
 
What sort of app are you talking about-- a web application or a client
application? If you have a web application, can't you just use relative
URLs everywhere?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Eric said:
What sort of app are you talking about-- a web application or a client
application? If you have a web application, can't you just use
relative URLs everywhere?

Thanks for the response. It's a web application (forgot to mention, but
thought it would be assumed on a ASP.net forum)

Well, I can use relative links everywhere until I want to switch from http
to https. I used to develop web applications with this environment call West
Wind Web Connect (www.west-wind.com) which is VFP-based. It has this great
function called GetRelativeSecureLink that would return an absolute https
link from a relative http one. Great for when you are going to the "Secure
checkout" area and want to turn on ssl.

Now I find that with asp.net there is no such function so I need to come up
with something else.
I was thinking that if I had a way to return the full absolute URL I could
just do some string manipulation to go from http to https.

Got any better ideas? Seems like this would be a very common issue. Maybe
I'm missing a key point somewhere along the line...

Matt
 
If you're using relative hyperlinks everywhere, then in theory you'd only
need to use the full HTTPS url at the one point at which the user enters the
"secure" area, right?

There's probably a few ways to do this.

First, have you seen the ~ operator? It might solve your problem neatly.

You could probably use the Server.MapPath() function to turn a relative link
into an absolute link, then change the protocol.

You could get the current URL using Request.ServerVariables("URL")and
perform some simple string manipulations on it.


--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top