Skip to Content, PHP, MySQL, Javascript, Ajax, Htacces

MVC Interview Questions and Answers For Graduates Part-5

Be First!

MVC-Diagram41.Can a view be shared across multiple controllers? If Yes, How we can do that?
Yes we can share a view across multiple controllers. We can put the view in the “Shared” folder. When we create a new ASP.Net MVC Project we can see the Layout page will be added in the shared folder, which is because it is used by multiple child pages.

42.What are the components required to create a route in ASP.Net MVC?
Name – This is the name of the route.
URL Pattern : Placeholders will be given to match the request URL pattern.
Defaults :When loading the application which controller, action to be loaded along with the parameter.

43.Why to use “{resource}.axd/{*pathInfo}” in routing in ASP.Net MVC?
Using this default route – {resource}.axd/{*pathInfo}, we can prevent the requests for the web resources files like – WebResource.axd or ScriptResource.axd from passing to a controller.

44.Can we add constraints to the route? If yes, explain how we can do it?
Yes we can add constraints to route in following ways :

Using Regular Expressions
Using object which implements interface – IRouteConstraint.

45.What are the possible Razor view extensions?
Below are the two types of extensions razor view can have :

.cshtml : In C# programming language this extension will be used.
.vbhtml – In VB programming language this extension will be used.

46.What is PartialView in ASP.Net MVC?
PartialView is similar to UserControls in traditional web forms. For re-usability purpose partial views are used. Since it’s been shared with multiple views these are kept in shared folder. Partial Views can be rendered in following ways :


47.How we can add the CSS in ASP.Net MVC?
Below is the sample code snippet to add css to razor views : < link rel=”StyleSheet” href=”/@Href(~Content/Site.css”)” type=”text/css”/>

48.Can I add ASP.Net MVC Testcases in Visual Studio Express?
No. We cannot add the test cases in Visual Studio Express edition it can be added only in Professional and Ultimate versions of Visual Studio.

49.What is the use .Glimpse in ASP.Net MVC?
Glimpse is an open source tool for debugging the routes in ASP.Net MVC. It is the client side debugger. Glimpse has to be turned on by visiting to local url link – http://localhost:portname//glimpse.axd This is a popular and useful tool for debugging which tracks the speed details, url details etc.

50.What is the need of Action Filters in ASP.Net MVC?
Action Filters allow us to execute the code before or after action has been executed. This can be done by decorating the action methods of controls with ASP.Net MVC attributes.



Leave a Reply