0

Does it need Certificate/License/Registration before launching the website using https?

I want to use the mentioned code in Global.asax file.

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] 
+   HttpContext.Current.Request.RawUrl);
}
0

2 Answers 2

1

First of all, I think you will never reach it, as it will loop in the Application_BeginRequest over and over as you are redirecting all requests...

Maybe what you're after is redirecting if the request comes from a non secure connection (http), no?

for that, see if the request comes from such connection like:

  protected void Application_BeginRequest(object sender, EventArgs e)
  {
     if (!HttpContext.Current.Request.IsSecureConnection)
        Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri.Replace("http://", "https://"));
  }

Secondly, the HTTPS protocol needs to be up and running or you will get a ERR_SSL_PROTOCOL_ERROR error thrown.

In Visual Studio, you can easily enable https in the project properties

enter image description here

and you will get the untruest warning

enter image description here

As Visual Studio generated (on installation) a default self signed certificated.

In production environment you will need to:

  • if it's an intranet application, just use the self-signed certificate
  • on a internet application, you do need to buy an SSL certificates, now-days they re cheaper and cheaper...

From your comments I have some question myself now...

  • Do you understand what HTTPS does to the connection between client computer and server?
  • Do you really need a secure connection between the two?
  • What kind of data are you trying to secure?
Sign up to request clarification or add additional context in comments.

6 Comments

Will it be possible for you to share a link over Request comes from a non secure connection ?
Web.Config will be fine in this context ? If so, will it be possible to share a code link over it ?
share a link sure, you will get that annoying warning in the browser saying that some data is not secure, but sure you can! web.config is just a place to set application settings, no need to change any of it to work in secure and nonsecure connections...
Do you understand what HTTPS does to the connection between client computer and server? No. Do you really need a secure connection between the two? Yes. But With best technique. What kind of data are you trying to secure? I have a query here. Can you tell exactly what issues can come if I use http ?
what kind of query? a SQL query?
|
0

When you want to use secure HTTP (using the HTTPS protocol) you say that the traffic between the browser and server is encrypted.

This means you need a certificate on the server so that the browser and server can decide on how to encrypt the traffic.

This has nothing to do with redirects and everything to do with your server setup.

5 Comments

When you said traffic between the browser and server is encrypted. Can you give some detailed link over it please ? Thanks you so much for the reply.
@Guest - Did you look at the link I provided?
Sorry. I will go through it first. Thanks.
My query is after reading the article. HTTPs keep user communications and browsing history private. So Browsing History is always private. As it is on individual machine. Right?
@Guest - Private means that the history is only known between the browser and server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.