From non-ssl area to ssl ara with a virtual href path?

6

620

I have a simple link/href in the 'default' http/80 area that points the user
to the 'secure' https/443 area, which is just a sub-folder that requires
SSL. Before SSL was implemented, I used a virtual href
("/securearea/main.aspx") but once I implemenet SSL, I get that "You must
prefix the url with https://..." error page.

And I generally understand why I'm getting that error (because ssl doesn't
use http/80, it uses https/443, and I'm guessing a virtual path ultimately
inherits the current http/s/port settings). But now I'm wondering is there
a way to use a virtual href for this at all, or do I absolutely need to
provide the full url when pointing into SSL-territory, i.e. https://etc ? I
only ask because my dev machine and the live machine have different URLs and
run on different ports (but beyond that, have the same file structure), and
so far I've been using virtual pathing and avoided the need for those
annoying global dev/live variables that must be switched every time you
compile live content.
 
C

Craig Deelsnyder

620 said:
I have a simple link/href in the 'default' http/80 area that points the user
to the 'secure' https/443 area, which is just a sub-folder that requires
SSL. Before SSL was implemented, I used a virtual href
("/securearea/main.aspx") but once I implemenet SSL, I get that "You must
prefix the url with https://..." error page.

And I generally understand why I'm getting that error (because ssl doesn't
use http/80, it uses https/443, and I'm guessing a virtual path ultimately
inherits the current http/s/port settings). But now I'm wondering is there
a way to use a virtual href for this at all, or do I absolutely need to
provide the full url when pointing into SSL-territory, i.e. https://etc ? I
only ask because my dev machine and the live machine have different URLs and
run on different ports (but beyond that, have the same file structure), and
so far I've been using virtual pathing and avoided the need for those
annoying global dev/live variables that must be switched every time you
compile live content.

Yes, the only way to do this is to provide a complete URL, as a relative
one uses the same http:// prefix. Remember if you send https:// to the
browser, it will assume 443, as that is the normal port that is used.
Otherwise send http://myserver:445/ if you run SSL over port 445 (or for
an address that doesn't run over port 80).

But you'll have to rebuild the URL yourself using the Request properties
and/or Control.ResolveUrl. You shouldn't have to hardcode anything; if
you need varying values, put values in the web.config (for port numbers,
etc.).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top