Techbubbles

Security and Configuration Enhancements for ASP.NET Projects in VS 2013

Number of enhancements made for ASP.NET Projects in Visual Studio 2013 release. For example, Now you can easily create a Web Forms project which has MVC as a part of it or you could create MVC project which has Web Forms. This release also enabled switching authentication types per project, For example you can create a MVC project that uses Windows Azure Active Directory or you can select individual Authentication, Oauth or Windows. This post outlines the overview on Configuration and Different authentication options that are available for ASP.NET.

When you create a new Web Forms project in Visual Studio 2013, you will notice there is only one project template , in VS 2013 there were different templates

image

when you hit ok then you will see the new ASP.NET project template , there different options available for to pickup such as folders for MVC, Web API and Test Projects

image

Click Change Authentication which enables you to select the different authentications that you like to use for the project which gets created.

image

Individual User Accounts allows you to sign in with username and password or to use social accounts twitter,Facebook or Microsoft. Organizational accounts are all about active directory and Windows Azure AD. Click ok to create your project, In earlier versions it is difficult to add the custom profile data to the database. Now you can do easily as shown below, Run the application and click the register button to add a user to database

image

when you click Register AccountController in your project contacted the database which will store your user information. Now navigate to the Server Explorer and navigate to the AspNetUsers Table and say ShowTableData

image

Now open the IdentityModels.cs file in Models folder and add two custom properties that you want to add to the user

image

Also update the view to enter the information by opening Register.aspx file from Account folder

image

open the Register.aspx.cs file and add the below code to ApplicationUser block

image

Now update the database in-order to have these columns using Entity Framework code first migrations 

image

image

Now execute the application and now you should be able to register with new fields, when registration is complete then you can find the additional user profile information in database.

Coming back to authentication mechanism, under organizational accounts you can use either single tenant AD or Multi tenant AD or onPremises AD

image

If you select Cloud-Single Organization and say ok then it prompts for to enter credentials

image

once you enter the credentials then it takes you back to the application home page.

Related Posts:

%d bloggers like this: