ScottHa has a great blog Working with SSL at Development Time is easier with IISExpress, but I’ve got what I think is a better approach. Please weigh in.
In this blog entry I’ll show you how to test SSL on your ASP.NET MVC & WebForms applications using IIS 7. You should make sure you have IIS 7 set up on your Windows 7 computer before proceeding. See my blog Test your ASP.NET MVC or WebForms Application on IIS 7 in 30 seconds for instructions.
Create a new ASP.NET MVC 3 Application called MvcSSL in the C:\Webs folder. Accept all the defaults.
WARNING: IIS cannot run an ASP.NET project that has been created in the default Visual Studio project folder (C:\users\<user>\Documents\Visual Studio 2010\Projects). Select a folder where IIS can access the files, such as C:\Webs.
Build and run the application.
Right click the solution and select Properties.
Should you get the message:
Unable to create the virtual directory. To access Web sites on the local IIS Web server, you must run Visual Studio under an Administrator account.
Read it and follow the directions and you’ll be rewarded with a friendlier message.
Now go back to IIS manager, refresh and drill down in the Default Web Site. Select Browse *:80(http) in the right pane.
That’s it. You now have a self signed certificate for testing.
Open Global.asax and add RequireHttps to all controllers and action methods.
public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new RequireHttpsAttribute()); filters.Add(new HandleErrorAttribute()); }
Build the application and refresh the browser. Note IIS Manager now includes the SSL port.
Click on the lock icon to examine the certificate.
Change the URL to use the machine name instead of localhost.
To access this site from a remote computer, you’ll probably have to open up port 443.
5. On the Action page, click Allow the connection, and then click Next.
6. On the Profile page, make sure that the Domain, Private, and Public check boxes are selected, and then click Next to accept the default profile.
7. On the Name page, under Name, type something like World Wide Web Services (Rick’s HTTPS Traffic-In).
C:\Users\ricka\Downloads\SelfSSL7>SelfSSL7.exe /Q /T /I "Default Web Site" /N cn=Q1;cn=localhost / V 1000 /K 2048 /X /F q1.pfx /W 5$ecURE!