These are some of the Very Important Questions that you come across in your ASP.NET MVC programming life. Asp.net mvc interview questions and answers:

1. How to set default route to an Area in ASP.NET MVC?

Answer:
You need to add DataToken to Default Route, in order to make your area as default route in route.config. for eg:- You have seperate area for login related files and want to be your default route during your application startup.

              routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { area= "Login", controller = "Login", action = "Index", id = UrlParameter.Optional }
            ).DataTokens.Add("area","Login");

2.What are the return types of controller action methods?

Answer:

3.What are Filters in MVC?

Answer:
In MVC,sometimes we need to perform action before or after particular method or operation. Types of Filters:

4.What are action filters?

Answer:
These are special attributes which can be applied to either a controller or action methods.It can be executed before and after controller action executes.

5.What are different types of action filters?

Answer:

6.What is Authorize? Give an example.?

Answer:
It allows only authorize users to login to the application. For non authorized user , it goes to login page.

    
        [Authorize]
        public ActionResult Index()
        {
        ViewBag.Message = "This page is viewed only by authorized user";
        return View();
        }

    

7.What is Routing? What are the 3 segments of Routing?

Answer:
Routing helps you to define the URL structure and map the URL with the controller.Routing happens on the basis of URL pattern
The 3 segments of routing are:
Controller name
Action method name
Parameter
Please see in Route.config file of your mvc application.

8.How can we maintain session in ASP.NET MVC?

Answer:
SESSION can be maintained in MVC in 3 ways.

9.What is Viewdata?

Answer:
It is useful for transfering data from controller to view.it is again a keyvalue pair.

10.What is ViewBag?

Answer:
Viewbag is useful when you want to transfer data from controller to view.The viewbag is dynamic property of controllerbase class

11.What is Tempdata?

Answer:
It is again a key value pair.It is used when data is to be used in two subsequent request.It can be between 2 actions or 2 controllers.You cant get the tempdate value in 3 rd request,