Dot Net Stuff

Understanding ASP.NET MVC Filters and Attributes

ASP.NET MVC Filters allow us to inject extra logic into MVC Framework request processing, this logic either before or after an action is executed. They provide a simple and elegant way to implement cross-cutting concerns. This term refers to functionality that is used all over an application and doesn’t fit neatly into any one place, where it would break the separation of concerns pattern. Classic examples of cross-cutting concerns are logging, authorization, and caching. In this article, I will show you the different categories of filters that the MVC Framework supports, how to create and use filters, and how to control their execution. We can make your own custom filters or attributes either by implementing ASP.NET MVC filter interface or by inheriting and overriding methods of ASP.NET MVC filter attribute class if available.

Continue Reading>>

Understanding Model Binding in ASP.NET MVC with Example

A view can display a form that has fields such as text boxes, check boxes, radio buttons, and so forth, and a submit button. When the user submits the form, the information in the fields is sent to the controller.ASP.NET uses an HttpRequest object to handle requests. Information coming in the request is stored in different collection objects depending on how the request was sent and the type of information. For example, if the request was sent via HTTP GET, such as http://www.DotNet-Tutorial.com/page?id=1&v=true, then the values for the parameters id and v are stored in the HttpRequest.QueryString collection. If the request is sent using HTTP POST, then the values are stored in the HttpRequest.Form collection. Uploaded files are stored in the HttpRequest.Files collection. If the request is based on a route, then the values are stored in the RouteData.Values dictionary.

Continue Reading>>

Attributes in Routing in ASP.NET MVC with example:

Routing in Asp.NET MVC is how ASP.NET MVC matches a URI to an action. ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users. You can find more details about ASP.NET MVC Routing in separate articles. Here, I am going to discuss about Attributes in Routing in ASP.NET MVC.Now, you are able to know what following code says.

Continue Reading>>

Understanding Routing in ASP.NET MVC with example

Routing in Asp.NET MVC is how ASP.NET MVC matches a URI to an action. ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users. It is a part of all the MVC versions but MVC 5 supports a new type of routing, called attribute routing. As the name implies, attribute routing uses attributes to define routes. Attribute routing gives you more control over the URIs in your web application. There is a separate article to understand Attributes in Routing in ASP.NET MVC.

Continue Reading>>

What is ASP.NET Web API ? Why to Choose ASP.NET Web API ?

ASP.NET Web API is a framework that allows us to build HTTP services that reach a broad range of clients, including browsers, mobile devices, and tablets. For creating RESTFul applications, ASP.NET Web API is an ideal platform on the .NET Framework. As it contains ASP.NET MVC features such as routing, controller, action results, filter, model binding, thus it is very easy to create application for ASP.NET WEB API. Here, one thing we should keep in mind that Asp.Net Web API is not a part of ASP.NET MVC. ASP.NET Web API is a part of code ASP.NET platform and it can be used with ASP.NET MVC or any other types of application or it can be a standalone service application.

Continue Reading>>

Understand ASPX and Razor View Engine

ASP.NET MVC is one of the most popular frameworks for these days and the term “View Engine” is belongs to that. I this section we are try to understand about Razor View Engine and ASPX View Engine.


Introduction of View Engine

There are two types of view engine supported by ASP.NET MVC. In this Article we will go through the Razor and ASPX view engine View Engines are responsible for rendering the HTML from your views to the browser. The view engine template will have different syntax for implementation.

What is @Razor ?

Razor using an @ character instead of aspx's <% %> and Razor does not require you to explicitly close the code-block, this view engine is parsed intelligently by the run-time to determine what is a presentation element and what is a code element. Razor view engine is compatible with unit testing frameworks. This is the default view engine in MVC 3 and MVC 4. Web pages with Razor syntax have the special file extension cshtml (Razor with C#) or vbhtml (Razor with VB).

Continue Reading>>

ASP.NET MVC Overview

MVC is acronym of Model – View – Controller, is a software design pattern, which divide software application in to three major interconnected parts.

  1. Model- It is a class which is used to show or update view by using business logic. It is also used to validate user input. e.g. Employee, Student, etc. 
  2. View – It is responsible to interact with users, it is the component that display the application to users. E.g. Textbox, Checkbox, etc. 
  3. Controller- It is responsible to accept the request from the view, works with the model and select the view to render to display the User Interface (UI).Continue Reading>>

Features of ASP.NET MVC

The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications. The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as membership-based authentication and master pages. The MVC framework is defined in the System.Web.Mvc namespace and is a fundamental, supported part of the System.Web namespace.Continue Reading>>

Understanding HTML Helpers in ASP.NET MVC Framework.

One of the most important purpose of server controls in ASP.NET —favoring HTMLlevel code reuse. ASP.NET MVC doesn’t have the server controls but it have. To achieve these features in MVC, It needs be built programmatically based on dynamically discovered data. What’s a technology equivalent to server? controls in ASP.NET MVC? Here comes the sense of HTML helpers.

HTML helpers certainly are not the same as server controls, but they are the closest you can get to HTML-level code reuse with a view engine. An HTML helper method has no view state, no postbacks, and no page life cycle and events. HTML helpers are simple HTML factories. Technically, an HTML helper is an extension method defined on a system class—the HtmlHelper class—that outputs an HTML string based on the provided input data. Internally, in fact, an HTML helper simply accumulates text into a StringBuilder object.


HTML helpers can be classified into three categories.Continue Reading>>