What are Action methods in ASP.NET MVC?

Controller actions are methods defined in the controller class and responsible to perform required operations on the user’s inputs like as form values, query strings values etc. with the help of Model and passing the results back to the View. Asp.net MVC has the following built-in ActionResults Type and Helper… Continue reading

How to control Session behavior in ASP.NET MVC?

By default, ASP.NET MVC support session state. Session is used to store data values across requests. Whether you store some data values with in the session or not ASP.NET MVC must manage the session state for all the controllers in your application that is time consuming. Since, session is stored… Continue reading

What are differences among ViewData, ViewBag, TempData and Session?

In ASP.NET MVC there are three ways – ViewData, ViewBag and TempData to pass data from controller to view and in next request. Like WebForm, you can also use Session to persist data during a user session. ViewData ViewData is a dictionary object that is derived from ViewDataDictionary class. public… Continue reading

What are different ways of returning/rendering a view in ASP.NET MVC?

There are four different ways for returning/rendering a view in ASP.NET MVC as given below: Return View() – This tells MVC to generate HTML to be displayed for the specified view and sends it to the browser. This acts like as Server.Transfer() in ASP.NET WebForm. Return RedirectToAction() – This tells… Continue reading

What is App_Start folder in ASP.NET MVC?

App_Start folder has been introduced in MVC4. It contains various configurations files like as BundleConfig.cs, FilterConfig.cs, RouteConfig.cs, WebApiConfig.cs for your application. All these settings are registered within Application_Start method of Global.asax.cs file. BundleConfig.cs – This is used to create and register bundles for CSS and JS files. By default, various… Continue reading

What are different ways of rendering layout in ASP.NET MVC?

There are following four different ways of rendering layout in ASP.NET MVC: Using _ViewStart file in the root directory of the Views folder: The _ViewStart file with in Views folder is used to server the default Layout page for your ASP.NET MVC application. You can also change the default rendering… Continue reading