How View Engine works?

Each view engine has following three main components: ViewEngine class – This class implements the IViewEngine interface and responsible for locating view templates. View class – This class implements the IView interface and responsible for combining the template with data from the current context and convert it to output HTML… Continue reading

What are important namespaces in ASP.NET MVC?

There are some important namespaces as given below: System.Web.Mvc – This namespace contains classes and interfaces that support the MVC pattern for ASP.NET Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial views, and model binders. System.Web.Mvc.Ajax – This namespace contains classes that supports… Continue reading

What is Route Constraints in ASP.NET MVC?

Route constraints is way to put some validation around the defined route. Creating Route Constraints Suppose we have defined the following route in our application and you want to restrict the incoming request url with numeric id only.Now let’s see how to do it with the help of regular expression…. Continue reading

What is difference between Routing and URL Rewriting?

Many developers compare routing to URL rewriting since both look similar and can be used to make SEO friendly URLs. But both the approaches are very much different. The main difference between routing and url rewriting is given below: URL rewriting is focused on mapping one URL (new url) to… Continue reading

How to define Attribute Routing for Area in ASP.NET MVC?

You can also define attribute routing for a controller that belongs to an area by using the RouteArea attribute. When you define attribute routing for all controllers with in an area, you can safely remove the AreaRegistration class for that area. [RouteArea(“Admin”)] [RoutePrefix(“menu”)] [Route(“{action}”)] public class MenuController : Controller {… Continue reading

How to enable Attribute Routing in ASP.NET MVC?

Enabling attribute routing in your ASP.NET MVC5 application is simple, just add a call to routes.MapMvcAttributeRoutes() method with in RegisterRoutes() method of RouteConfig.cs file. public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); //enabling attribute routing routes.MapMvcAttributeRoutes(); } } You can also combine attribute routing with convention-based routing…. Continue reading

When to use Attribute Routing?

The convention-based routing is complex to support certain URI patterns that are common in RESTful APIs. But by using attribute routing you can define these URI patterns very easily. For example, resources often contain child resources like Clients have orders, movies have actors, books have authors and so on. It’s… Continue reading