Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Contents tagged with MVC

  • Dealing with Profile Access in ASP.NET MVC Applications

    ASP.NET services such as Profile are available to MVC applications too and developers can make use of them when needed. While developing a Web Forms based website project developers can access profile properties in a strongly typed fashion. This strongly typed nature comes from the ProfileCommon class that is generated automatically in such projects. ASP.NET MVC and Web Application projects, however, lack this handy and useful feature. In this article you will learn how to access user Profile in ASP.NET MVC applications and also an alternative to overcome this limitation.

  • Emitting Exceptions from LINQ to SQL classes in ASP.NET MVC Validation Summary

    Recently while developing a sample application in ASP.NET MVC, I came across a peculiar situation. There was a LINQ to SQL class with several extensibility methods defined (OnXXXXChanging kind of methods where XXXX is the name of a property). The methods were performing some validation checks and in case of any violation were throwing exceptions. The LINQ to SQL class was working fine. However, at some places I wanted to display the validation errors (thrown by the class as exceptions) on the ASP.NET MVC views. That is where the problem began. No matter what exception you throw in the class the Validation Summary never displays the error message.

  • Understanding ASP.NET MVC Model Binding

    ASP.NET MVC model binding allows you to map and bind HTTP request data with a model. Model binding makes it easy for you to work with form data because the request data (POST/GET) is automatically transferred into a data model you specify. ASP.NET MVC accomplishes this behind the scenes with the help of Default Binder. This article discusses how model binding works for various types of models viz. simple types, class types and lists. It also shows how to create a custom model binder if situation calls for it.

  • Validating Data in ASP.NET MVC Applications

    Validating data entered by the user is one of the most common tasks in web applications. As far as ASP.NET MVC is concerned there are various ways to accomplish this task. As a web developer you should be aware of these options so that depending on your requirement you need to pick the appropriate one. This article discusses many of the available options and also shows in step-by-step manner how these options can be put to use in your ASP.NET MVC application.

  • Improving Performance of ASP.NET MVC Applications Using Caching Features

    Developers frequently look for opportunities to squeeze the last drop of performance from their web applications. In ASP.NET web forms and user controls Output Caching is a very popular performance enhancement technique. The same technique can also be implemented in ASP.NET MVC applications. Upon applying the Output Caching techniques, the page output is cached so that further requests are served with the cached copy rather than processing and generating it again and again. In this article you will learn how Output Caching is used in ASP.NET MVC applications along with some considerations involved in the process.

  • Using GridView and DetailsView in ASP.NET MVC - Part 1

    For any beginner in ASP.NET MVC the first disappointment is possibly the lack of any server controls. ASP.NET MVC divides the entire processing logic into three distinct parts namely model, view and controller. In the process views (that represent UI under MVC architecture) need to sacrifice three important features of web forms viz. Postbacks, ViewState and rich event model. Though server controls are not a recommended choice under ASP.NET MVC there are situations where you may need to use server controls. In this two part article I am going to explain, as an example, how GridView and DetailsView can be used in ASP.NET MVC without breaking the MVC pattern.

  • Creating ASP.NET MVC "Web Site"

    If you used ASP.NET MVC before, you are probably aware that Visual Studio provides ASP.NET MVC Web Application project template to create MVC based applications. There is no option to create MVC Web Sites. In this article I am going to explain how I solved this issue in one of my application.