Contents tagged with ASP.NET

  • Securing ASP.NET MVC Applications with ASP.NET Identity

    ASP.NET offers Forms Authentication as one of the authentication schemes. Developers often use Forms Authentication in combination with membership, roles and profile features to provide security to their web applications. Over the years the needs of authentication schemes used in a web application have changed. To take into account these changing trends Microsoft has released ASP.NET Identity - a new way to authenticate users of your web application. This article describes how ASP.NET Identity can be used in an ASP.NET MVC application from the ground up.

    Read more...

  • Using Display Templates and Editor Templates in ASP.NET MVC

    ASP.NET MVC developers often use HTML helpers such as LabelFor() and TextBoxFor() to display model properties on a view. Although this approach works fine in many situations, it proves to be inadequate when you wish to customize how data is presented to the user for displaying and for editing. Luckily, you can use display templates and editor templates to overcome this limitation. This article discusses what display templates and editor templates are and how to use them in an ASP.NET MVC application.

    Read more...

  • Learn ASP.NET MVC in Thane. Registration started for October 2014 batches !

    We will be conducting a 5 day intensive training program on ASP.NET MVC in the month of October 2014. Learn MVC5, EF6, Web API 2, VS2013 and more. Small batches, personal attention and real world examples. Registration has already started. In case you or your friends are interested to join please get in touch with us as soon as possible. The courses are conducted in Thane. You may read more details here.

    Read more...

  • Wrapping multiple calls to SaveChanges() in a single transaction

    When you make any additions, modifications and deletions to an Entity Framework DbSet and call SaveChanges(), EF starts a new transaction and executes all the INSERT, UPDATE and DELETE operations inside that newly created transaction. If the call to SaveChanges() succeeds the underlying transaction is committed, otherwise the transaction is rolled back. In some cases you may want that multiple calls to SaveChanges() be executed in the same transaction. Luckily, Entity Framework 6 provides an easy way to accomplish the same.

    Read more...

  • Self-Hosting an ASP.NET Web API

    ASP.NET Web API can be either be hosted in IIS or in a separate host process. The former approach is usually appropriate when the Web API is part of a web application and one or more web applications are going to consume it. The later approach is suitable when you wish to avoid the overhead of hosting the Web API in IIS and want to have something lightweight. Hosting a Web API inside IIS is quite straightforward as the process is identical to hosting a web application. On the other hand, hosting a Web API in it's own process requires the creation of a host application and is referred as self-hosting. This article shows in step-by-step manner how to self-host a Web API and how to consume it using a client application.

    Read more...

  • What to do when SaveChanges() fails?

    Beginners often ask this question - "What course of action should I take when a call to SaveChanges() fails?" The answer may vary based on a given situation and requirement. This article discusses one way to deal with the errors and shows how to display descriptive error messages to the end user and then rollback the changes made to the model.

    Read more...

  • Passing data from one controller to another in ASP.NET MVC

    At times you need to pass data from an action method belonging to one controller to an action method belonging to another controller. There are three ways to accomplish this task. They are - Pass data as query string, pass data in TempData, and pass data as route parameters. Let's quickly see how each of these three approaches work.

    Read more...

  • Overview of OWIN and Katana

    As OWIN is becoming popular and more common, it is important for ASP.NET developers to understand what OWIN and Katana are. ASP.NET Web API and ASP.NET Identity are already geared towards using these specifications. To that end this article explains what OWIN and Katana are and how they fit into the whole web development picture for ASP.NET developers. You will also develop a simple application to get a code level understanding of these features.

    Read more...

  • Creating Your Own "TempBag" in ASP.NET MVC

    Some time back during one of my training programs I was asked this question by a beginner in ASP.NET MVC - "Can we have TempBag wrapper for TempData just as we have ViewBag for ViewData?" Whether such a wrapper is needed is not is a different question but if you wish you can create one using dynamic objects of C# language. Here I am going to show a quick way to wrap TempData into our own TempBag and then using it in the controller and view.

    Read more...

  • Video : How to Organize Your ASP.NET MVC Solution in Visual Studio?

    A lot of beginners ask this question - How should I organize my MVC projects? There is no fixed answer to this question because a lot of things depend on the size and complexity of the system being developed. However, beginners need a starting point from where they can take it forward. To that end, this video shows one possible organization of various parts of an MVC application. Remember that my aim is to present a simple and structured organization that can easily be extended or modified as per requirement.

    Read more...