Change Scheme From HTTP To HTTPS On PostBack

  • Thread starter Thread starter Andrew Hayes
  • Start date Start date
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?
 
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.
 
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.
 
Back
Top