c# have a page use https

in page_load I'm trying:

            //this is the current url

            System.Uri currentUrl = System.Web.HttpContext.Current.Request.Url;

            //don't redirect if this is localhost

            if (!currentUrl.IsLoopback)

                if (!currentUrl.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.CurrentCultureIgnoreCase))

                    //build the secure uri

                    System.UriBuilder secureUrlBuilder = new UriBuilder(currentUrl);

                    secureUrlBuilder.Scheme = Uri.UriSchemeHttps;

                    //use the default port.

                    secureUrlBuilder.Port = -1;

                    //redirect and end the response.




but get an error :/

i.e. my payment screens need to use https
i.e. my profile screens need to use https

I thought this would work but it fails :/
Who is Participating?
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.

roddevAuthor Commented:
it does replace http with https
Miguel OzSoftware EngineerCommented:
Please check that your site has SSL (HTTPS) enabled.
E.g. If you use your HTTPS URL in the browser does it work OK? (The wb page does not show error above)
Also you need to check if you have proxy or firewall restrictions.
Agree with mas_oz2003
If it was security cert problem then firefox would say there is a problem with it but it looks like your server doesn't even know what to do with https

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
roddevAuthor Commented:
the sad thing is the control panel has the ssl certificates installed.  however it apparently does NOT setup IIS even though it says its got https configured.  I'll install the certificates on IIS itself and not let the control panel know about it (just like I had to run everything in the application pool for .net 4.0)
roddevAuthor Commented:
not really
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

From novice to tech pro — start learning today.