Switch to SSL on load

I am trying to force a page to switch to SSL when loaded. (If not it shows nothing since website only accepts SSL connection)

I am using ASP classic / VB

Help is appreciated.
LVL 1
AleksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nadav SolomonCommented:
Why not just redirect at the iis level?
AleksAuthor Commented:
How do I do this ?
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Dave BaldwinFixer of ProblemsCommented:
SSL/TLS encrypt the connection when you first request it.  You can not switch without completely reloading the page.  At that point the usefulness of SSL and HTTPS is gone.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Actually after careful review we need it to switch to the value of a parameter we have in our 'parameters'   table. the paramnm = 'procotocol'  and the values are either 'http'  or 'http'
This is because when we are running in a test environment and computers we need it to be http.

I have this code but this works only for ASP/JavaScript and this login page is ASP / VBscript

<% if (!Parameterhttps.EOF || !Parameterhttps.BOF) { %>
<% 
	var vURL, vOnOff
	switch("Secured") {
		case "Secured":
			vURL = "https://";
			vOnOff = "on";
			break;
		case "UnSecured":
			vURL = "http://";
			vOnOff = "off";
			break;
	}
	if(String(Request.ServerVariables("HTTPS")) != vOnOff)  {
		vURL = vURL + Request.ServerVariables("Server_Name") + Request.ServerVariables("URL");
		if (Request.QueryString().Count > 0) vURL = vURL + "?" + Request.QueryString();
		Response.Redirect(vURL);
	}
%>
<% } // end !Parameterhttps.EOF || !Parameterhttps.BOF %>

Open in new window


Can we have something similar for ASP VB ?
Nadav SolomonCommented:
Glad I could help, thanks for the feedback.
AleksAuthor Commented:
It was ok, but not what I needed. What I needed was a script that would check a value in the database table: parameters  field: prot

If the value is:  http  leave connection as http, if its https then set the connection to https.

The script I have above does that for ASP/JavaScript. I need the same but for ASP/VB script.

So I will repost later today.  

On IIS I do force https connection so right now it gives me an error because I don't have the script to switch the page to https
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.