What is MVC?

MVC is a framework and stands for Model – View – Controller. It is another way to create web based application. As compare to Asp.net form based application it is quite light weighted.

For Complete Details Click Here


What is Routing in MVC

Routing is the way to create user friendly and descriptive url.

Can we have more than one route in mvc

Yes we can have

For Complete Details Click Here


What is Razor?

Razor is a view engine and very powerful concept which is introduced in MVC 3. Razor is simply a new programming language which allows you to embed your C# and VB code with HTML. When we create Razor for C# then it adds .cshtml file but when we create Razor with vb then it add .vbhtml file.


what is the default http request of MVC?

Get is the default http request of MVC application.


which request is used to fetch data from view to controller using FormCollection?

FormCollection is based on Post Request.

For Complete Details Click Here


what is ViewData?

ViewData is used to access data from controller to corresponding view. ViewData stores data as key-value format. ViewData type is ViewDataDictionary.

For Complete Details Click Here


what is ViewBag?

ViewBag is used to access data from controller to corresponding view. ViewBag used dynamic property which introduced in C# 4.0. It is actually a Dynamic ViewDataDictionary.

For Complete Details Click Here


Difference between ViewBag and ViewData

In MVC both ViewBag and ViewData is used to pass data from controller to corresponding view. Both are the properties of ControllerBase class. There are following difference between these two:-


What is HTML Helper

In MVC, many helper methods are added to create HTML control perfectly. As in Web Application we use control class to create control in asp.net, here we use HTML helper classes. But these methods are very light weight as they not maintain any viewstate and return as string.

For Complete Details Click Here


What is Model

In MVC ‘M’ stands for Model. In MVC model is used to create logic class for any MVC application. We can put all our project logic called business logic in model in MVC.

For Complete Details Click Here


What is Strongly View

In MVC when we bind a view with particular model then it is known as strongly view.

For Complete Details Click Here


What is updatemodel

UpdateModel is the method which is generics type and takes parameter of model type. This method fills the value to the property of this model class.


What is actionlink in html helper

ActionLink is used to generate hyperlink in MVC using HTML Helper Class.

For Complete Details Click Here


What is ViewStart in MVC

Razor View Engine introduced a new layout named _ViewStart which is applied on all view automatically. Razor View Engine firstly executes the _ViewStart and then start rendering the other view and merges them.

For Complete Details Click Here


What is web api

Web API is a platform to create Restful Services which is based on HTTP Request.

For Complete Details Click Here


What is the difference between mvc and web api


What is @url.Content in MVC

@url.Content is used to handle any url of resource’s relative path like image, file etc. For example if you wish to display image then you will use @url.Content in the following manner

		<img src="@Url.Content(‘relative path of image’)" alt="user image" /> 
		

For Complete Details Click Here


What is Area in MVC

Area introduced in MVC 2. It is basically logical grouping of project which create separate Model, View and controller folder for each group or module.

For Complete Details Click Here


How to implement CSS in MVC

By using Style Attribute

		@Html.Label("Enter your First name", new { style = "background-color:green; color:white; font-family:Arial" }) 
		

By using Class:-

Create css class

		.LableStyle { background-color:green; color:white; font-family:Arial}
		

Pass this class to control

		@Html.Label("Enter your First name", new { @class="LableStyle" })
		

For Complete Details Click Here


Which filter use to implement authorization

[Authorize] filter is used.


Which filter helps to allow all users

[AllowAnonymous] is used.


How to return Json data from MVC

We have to covert data into json by using Json function
Json(data,JsonRequestBehavior.AllowGet);

		

What is nonaction attribute

In mvc controller every function is treated as an action and can be rendered by http request. If we want to stop the rendering of this function we use nonaction attribute to specify this is not action but a function.


What is filter in MVC

Filters are the custom classes which allow us to write our logic before or after the action execution.

What is Section

Section is the code of area which we define in html and these codes rendered in master page or layout in mvc.


Which function is used to render section

@RenderSection(“Section Name”).