Here is an ASP.NET MVC project template using CSU’s eIdentity WebAuth service. Getting started is fairly straight forward.

First you will need an eService Token. If you do not have a spare one around the shop, request one from the eService folks.

Next download the above file. Save it to My Documents/Visual Studio 2010/My Exported Templates. There is no need to uncompressed the file.

Now create a new Visual Studio 2010 C# solution. Select TemplateMVC2 from the project template choices.

Edit the solution’s Web.Config. In Web.Config, find the eServiceToken key and enter the token issued to you.

Lastly, log into the eService manager and edit the token’s WebAuth Result Destination. In traditional web applications we would point this to a particular page in our web application. This is not the case in MVC. Instead we point it to the WebAuthController’s Result ActionResult,  Example, if your application lived on wsnet the url would be,

That’s it!

Some Notes

Code Templates

The template includes Visual Studio’s CodeTemplates (Program Files/Microsoft Visual Studio 10.0/Common7/IDE/ItemTemplates/CSharp/Web/MVC 2/CodeTemplates). The file has been modified so that all newly created controllers will inherit properties from the BaseController. You should really check out CodeTemplates whether you are an MVC person like me or an old school .Net forms guy like my co-worker. They will save you lots of time.

Repository Pattern

The template also uses a repository pattern to keep things DRY and testable. The BaseController wires up the Service layer where all the business and validation logic takes place. The Sevice Layer connects to the Repository where all the data access logic occurs.