Using secure(https) connections.

Posted by Abhisek under ASP.NET category on | Views : 2223
To access a secure page that uses https is a little bit different. To access a https page in your web application you need to pass the absolute url of the page. So instead of adding that url to every page that request a secure page you can use the "AppPath " property of the <appSettings> in the web.config file. Just change you web. config file and add the following code to it.

<configuration xmlns="">
<add key="AppPath" value="//localhost/Retinaa/"/>

Here "//localhost/MyApp/" is the common path for every page.

Then you have to retrieve the application path from the web.config file. When any page want to access a secure page you have to use the following code,

string url = "https:" + ConfigurationManager.AppSettings["AppPath"] + "Login.aspx";

It will pass the complete url to the Redirect() method. Here Login.aspx is the secure page i want to access.

Similarly if you want to access an unsecure connection(http) from any secure page use the following code while requesting that page,

string url = "http:" + ConfigurationManager.AppSettings["AppPath"] + "Home.aspx";

Comments or Responses

Login to post response