Monday, November 17, 2014

Creating Web Application in Visual Studio 2013 Update 4

Templates used in Visual Studio for web applications were updated a lot recently.

Imagine we need to create ASP.NET Web Application using .NET Framework 4.5, Visual Studio 2013 with the latest Update 4 (available since November 12, 2014 http://www.visualstudio.com/news/vs2013-update4-rtm-vs#CodeLens).


Here we can add Application Insights feature to your project which should help us to understand what users are doing with our application, how often they launch it, in what environments, etc. For our test application we don't need it by now.

Next, we need to select template – basically it is – Empty, MVC or Web Forms:



We will select Web Forms now (we will select MVC template next time for our investigation). We don't need unit tests and hosting in the cloud for this project. In Change Authentication window we can change authentication from Individual User Accounts (default) to No Authentication, Organizational Accounts (i.e. Active Directory) or Windows Authentication (Intranet application).

So pressing OK and our template is being generated, actually got a lot of files!

Let's launch our solution and browse through pages.



We have Home, About, Contact, Register, Log in pages though we haven't written a single line of code yet. But what is more important we notice we have clean URLs without .aspx – like in MVC. This is achieved with the help of Microsoft.AspNet.FriendlyUrls library which was described by Scott Hanselman https://aspnetfriendlyurls.codeplex.com/ . Together with this library we have ViewSwitcher control allowing to switch between desktop and mobile views of the page.


Another techniques we should pay attention to are bundling and minification. Rick Anderson described them for Web Forms here:


Main target of using these techniques is to improve request load time. Code for creating bundles in in Global.asax.cs file. Look at Bundle.config file, there you can add your own files as well.

ASP.NET identity (logging in / registration of user) uses Microsoft OWIN Authentication middleware for forms authentication. OWIN (Open Web Interface for .NET) is an open source project which defines interactions between web servers and application components (owin.org). In References of our solution there are several assemblies related to OWIN, for example:

  • Microsoft.Owin.Host.System.Web - contains an OWIN server that enables OWIN-based applications to run on IIS using the ASP.NET request pipeline
  • Microsoft.AspNet.Identity.Owin - contains a set of OWIN extension classes to manage and configure OWIN authentication middleware


No comments:

Post a Comment