Pages

Monday, January 14, 2013

Use SSL in ASP.NET MVC3 Applcation

Hi fellas,

                                 SSL stands for Secure Socket Layer. Normally we use SSL in our web applications. We use it to secure the message transmission on the internet. This will secure the information we transmit via the URL. Different MVC applications use different methods to apply SSL to web application. In this section you will see how to use SSL with your ASP.NET MVC web application.

First of all we have to add related programming codes to the Web.config file of our web application. You can select the form to add this and if you want you can use this for several forms in your application. Bellow is the related XML code you should use in the Web.config file,

<forms loginUrl="~/Account/LogOn" timeout="2880" requireSSL="true"/>

In above XML code requireSSL="true" is the cording part which will take care of SSL. You can add any  related URL to the loginUrl according to your requirement. In above example it's loginUrl="~/Account/LogOn". 

After define Web.config file we have to modify the properties of our application project. to do this right click on the project and select properties.



In project properties select web tab and in that web tab  the Server properties scroll down to the Servers.


In that properties select Use Local IIS Web Server radio button. After that select Use IIS Express checkbox and Overide applicationroot URL checkbox.

Then go the project properties by double clicking on the project and you will get a window like bellow.


In the properties window set SSL Enable as True. After that copy the given URL in SSL URL and paste it on project URl and field under Overide application root URL checkbox like bellow,


Paste the copied URL like bellow,

After modify the web tab in project properties save the changes and the clean the project, Rebuild and run the project. Now your URL will include the https (SSL).

No comments:

Post a Comment