Change Scheme From HTTP To HTTPS On PostBack

A

Andrew Hayes

In my web application I have a page that lists product information taken from
a backend database, and a button for each item that shows a form within the
page for a user to enter some personal details to request more information.

This was achieved by using a FormView that is hidden until the user clicks
on the button to request information, at which point the C# code behind
formats the FormView based on the product selected and makes it visible so it
is shown when the page reloads.

However, for security reasons, when the page shows the form controls it
should be using HTTPS to protect personal information when it is posted.

Is there a way to change the scheme of a page, so that when the form
controls are shown it's HTTPS but when they are hidden it's HTTP?
 
J

Joern Schou-Rode

Is there a way to change the scheme of a page, so that when the form
controls are shown it's HTTPS but when they are hidden it's HTTP?

From microsoft.public.dotnet.languages.csharp:

An idea: whenever you are about to display the FormView, check the value
of Request.IsSecureConnection. If this one is false, do a redirect to a
patched URL, where HTTP is replaced with HTTPS, and some kind of locator
is added to the query string. When the page loads, check if a locator is
in your query string. If the locator is there, display the relevant
FormView - given that the connection is secure of course. If you wish, you
can redirect back to HTTP after the form data is recieved.
 
A

Andrew Hayes

Yes. This is what I've been trying, but so far I've not been able to set a
flag in the button event that is readable when I redirect the user to the
HTTPS page.
 

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

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top