MVC Interview Questions and Answers Part 5

By
1.) What are the features of ASP.NET MVC 5 ?                                                                     
There are some important features of ASP.NET MVC 5 as given below:-
  • MVC 5 released on 17 October  2013.
  • It runs on .NET Framework 4.5 ,4.5.1 and above.
  • It runs on visual studio 2012 and visual studio 2013.
  • It supports all the features of MVC 4 Template.
  • It supports ASP.NET Identity.
  • It provides authentication filters.
  • It supports Scaffolding functionality.
  • It support ASP.NET Web API 2.
  • It Support Bootstrap in ASP.NET MVC Template.
2.) How to use Custom View Engine in ASP.NET MVC  ?                                                 
If you want to use custom view engine in your mvc template ,you have to register it by using Global.asax.cs  file under Application_Start() method as given below.
protected void Application_Start() 
{  //Register Custom View Engine 
ViewEngines.Engines.Add(new CustomViewEngine());
...............other codes..........
 }

Note:- By using this above codes ,you can use custom view engine instead of default  one.

3.) Can You remove default View Engine in ASP.NET MVC  ?                                       
Yes,you can remove default view engines  (web form, Razor) from ASP.NET MVC as given below:-
protected void Application_Start() 
{ //Remove All View Engines 
   ViewEngines.Engines.Clear(); 
}

4.) What are HTML Helpers in ASP.NET MVC  ?                                                                
A HTML helper is a just a method that returns a HTML String .This string can represents any types of contents that you want.
We can use HTML Helpers to render standard HTML Tags such as 
  • <Input>
  • <output>
  • <img>
  • <Label>
  • <Button> etc.
Note:- You can also create your own HTML Helper to render more contents such as 
  • HTML Table
  • MenuScript
  • Database etc.
 5.) What are the types of  Helpers in ASP.NET MVC  ?                                                   
There are three types of helpers  in ASP.NET MVC as given below:-
  1. Inline HTML Helpers
  2. Built -in HTML Helpers
  3. Custom HTML Helpers
 6.) What are different types of  Built-in Helpers in ASP.NET MVC  ?                        
There are three  types of Built-in  Helpers  as given below:-
  1. Standard Html Helpers
  2. Strongly Typed HTML Helpers
  3. Templated  HTML Helpers
 7.) What are URL Helpers in ASP.NET MVC  ?                                                                    
The URL Helpers allow you to render HTML Links and raw URLs . The output of these helpers is dependent on routing configuration of your ASP.NET MVC application.
Examples:-
a.) Relative URL
@Url.Content("~/Files/Folder/msdotnet.doc") 
Output: /Files/Folder/msdotnet.doc
b.) Based on Action/Controller
@Html.ActionLink("Contact Us", "About", "Home")
 Output: <a href="/Home/About">Contact Us</a>
c.) Raw URL For Action
Url.Action("Interview", "msdotnet") Output: /msdotnet/Interview

 8.) What are Ajax Helpers in ASP.NET MVC  ?                                                                   
Ajax Helpers are used to create Ajax enabled elements like as Ajax enabled forms and links which performs request asynchronously. Ajax Helpers are extension methods of Ajax Helpers class which comes under System.Web.mvc name space.  
 9.) What is Partial view in ASP.NET MVC  ?                                                                        
A partial view is like as user control in ASP.NET Web Forms that is used for re-usability.It helps us to reduce code duplication.A Partial  views are a reusable views like Header and Footer views.
We generally use Partial view in following
  • Blog Commenting
  • Adsense
  • Calender
  • Product category etc.
Note:- We generally use "-" character before the partial view name but it is not mandatory.
10.) Can we change Action Method name in ASP.NET MVC  Application ?             
Yes, We can change action method name by using Action Name Attribute.Now this action method will be called by the name defined is action Name Attribute.
Example:-
[ActionName("Calculate")] 
public ActionResult Show() 
{ 
 return View(); 
}

Descriptions:-
In above example, "Show ()" action will be Identified and called by the name "Calculate".

0 comments:

Post a Comment

Powered by Blogger.