• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

asp.net 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 :/
  • 3
1 Solution
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
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now