10 Practical ASP.Net MVC 4 Interview Questions:
1) Do you think following is valid route definition for ASP.NET MVC solution?
Answer: YES. Variable length routes are valid. This route will match any URL, irrespective of number of placeholders it contains.
_________________________________________________________________
3) What is the primary difference between these two Html Helpers for Validation?
Answer: Latter displays only model level validation errors NOT the property level errors. Former displays both model and property level errors
__________________________________________________________
4) Does this Action Method compiles and
redirects the user to another view?
Answer: YES. It is a valid redirect.
_______________________________________________________________________
5) What is the difference between these Html Helpers?
Answer: Latter is destroyed after you read it while former preserves it for next request.
___________________________________________________________
6) What is the difference between two techniques? Which one to prefer?
Answer: They are one and same. We prefer second approach. It is built in helper method for controller to return 404 code
________________________________________________________________________
7) Can you override MVC convention and define controller name without ending in "Controller" as shown below?
Answer: YES. We can override default MVC convention to define controller name with out ending in "Controller". But, we have to implement our own custom controller factory.
________________________________________________________________________
8) What the result of this view? Will it be a runtime exception or just works fine?
Answer: Session Disabled controller has no impact on ViewBag. View Just renders fine with message: "My Controller has no session".
________________________________________________________________________
9) What is difference between @Url.Action and @Url.RouteUrl?
Answer: Semantically, they are same.
- Url.RouteUrl allows you to specify a particular route by name.
- Url.Action will simply pick the first route that matches the criteria.
________________________________________________________________________________
10) List out filters available in MVC world if you
can please specify their order of precedence?
Answer: Exception filter can kick in at any time.
- Authorization filter
- Action filter
- Result filter
- Exception filter