.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Alankar
SP
Sasi Prabhu
longwest
Kashmir


Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Post New Question Subscribe to Interview Questions
 
Quick Links For Interview Questions Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  OOPs  JQuery  JavaScript/VBScript
BiztalkPatten/Practices.IISWCFWPFWWF
NetworkingAptitudeOthers  All    
 

Interview Questions And Answers

What are the settings to be done for the Routing to work properly in an MVC application ?

Author: Alankar          Posted Date: April 06, 2015    Category: MVC     Points: 40

The settings must be done in 2 places for the routing to work properly.They are:

i) Web.Config File : In the web.config file, the ASP.NET routing has to be enabled.
ii) Global.asax File : The Route table is created in the application Start event handler, of the Global.asax file.

In an MVC application, what are the segments of the default route ?

Author: Alankar          Posted Date: April 06, 2015    Category: MVC     Points: 40

There are 3 segments of the default route in an MVC application.They are:

The 1st segment is the Controller Name.
Example: search

The 2nd segment is the Action Method Name.
Example: label

The 3rd segment is the Parameter passed to the Action method.
Example: Parameter Id - MVC

Explain about NonActionAttribute ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

It is already known that all the public methods of a controller class are basically treated as action methods.
If you dont want this default behaviour, then you can change the public method with NonActionAttribute. Then, the default behaviour changes.

xplain about 'page lifecycle' of ASP.NET MVC ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

The page lifecycle of an ASP.NET MVC page is explained as follows:

i) App Initialisation
In this stage, the aplication starts up by running Global.asax's Application_Start() method.
In this method, you can add Route objects to the static RouteTable.Routes collection.
If you're implementing a custom IControllerFactory, you can set this as the active controller factory by assigning it to the System.Web.Mvc.ControllerFactory.Instance property.

ii) Routing
Routing is a stand-alone component that matches incoming requests to IHttpHandlers by URL pattern.
MvcHandler is, itself, an IHttpHandler, which acts as a kind of proxy to other IHttpHandlers configured in the Routes table.

iii) Instantiate and Execute Controller
At this stage, the active IControllerFactory supplies an IController instance.

iv) Locate and invoke controller action
At this stage, the controller invokes its relevant action method, which after further processing, calls RenderView().

v) Instantiate and render view
At this stage, the IViewFactory supplies an IView, which pushes response data to the IHttpResponse object.

Mention some of the return types of a controller action method ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

An action method is used to return an instance of any class which is derived from ActionResult class.
Some of the return types of a controller action method are:
i) ViewResult : It is used to return a webpage from an action method
ii) PartialViewResult : It is used to send a section of a view to be rendered inside another view.
iii) JavaScriptResult : It is used to return JavaScript code which will be executed in the user's browser.
iv) RedirectResult : Based on a URL, It is used to redirect to another controller and action method.
v) ContentResult : It is an HTTP content type may be of text/plain. It is used to return a custom content type as a result of the action method.
vi) JsonResult : It is used to return a message which is formatted as JSON.
vii) FileResult : It is used to send binary output as the response.
viii) EmptyResult : It returns nothing as the result.

What is the use of a controller in an MVC application ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

A controller will decide what to do and what to display in the view. It works as follows:

i) A request will be received by the controller
ii) Basing on the request parameters, it will decide the requested activities
iii) Basing on the request parameters, it will delegates the tasks to be performed
iv) Then it will delegate the next view to be shown

Can we share a view across multiple controllers ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

Yes, It is possible to share a view across multiple controllers by putting a view into the shared folder.
By doing like this, you can automatically make the view available across multiple controllers.

Which namespace is used for ASP.NET MVC ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

System.Web.Mvc namespace contains all the interfaces and classes which supports ASP.NET MVC framework for creating web applications.


Does the unit testing of an MVC application is possible without running controllers in an ASP.NET process ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

In an MVC application, all the features are based on interface. So, it is easy to unit test a MVC application.
And it is to note that, in MVC application there is no need of running the controllers for unit testing.

Explain about Razor View Engine ?

Author: Alankar          Posted Date: April 02, 2015    Category: MVC     Points: 40

This Razor View engine is a part of new rendering framework for ASP.NET web pages.
ASP.NET rendering engine uses opening and closing brackets to denote code (<% %>), whereas Razor allows a cleaner, implied syntax for determining where code blocks start and end.

Example:

In the classic renderer in ASP.NET:

<ul>

<% foreach (var userTicket in Model)

{ %>

<li><%: userTicket.Value %></li>

<% } %>

</ul>



By using Razor:
<ul>

@foreach (var userTicket in Model)

{

<li>@userTicket.Value</li>

}

</ul>


« Previous12345678910….484485Next »


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend