ASP.NET MVC Flashcards

1
Q

What is ASP.NET MVC?

A

ASP.NET MVC is a web development framework from Microsoft that is based on the MVC architectural design pattern.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the Core features of ASP.NET MVC?

A

Clear separation of application concerns (Presentation and Business Logic). It reduces complexity that makes it ideal for large scale applications where multiple teams are working.

It provides extensive support for URL Routing

It supports for Test Driven Development (TDD) approach. In ASP.NET Web Forms, testing support is dependent on a Web Server but ASP.NET MVC makes it independent of a Web Server, database or any other classes.

Support for existing ASP.NET features like membership and roles, authentication and authorisation, provider model and caching etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Routing in ASP.NET MVC?

A

ASP.NET MVC framework uses a routing engine that maps URLs to controller classes.

We can define routing rules for the engine, so that it can map incoming request URLs to the appropriate controller.

When a user types a URL in a browser window the routing engine uses routing rules that are defined in the Global.asax file in order to parse the URL and find out the path of corresponding controller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between ViewData, ViewBag and TempData?

A

Both ViewBag and ViewData are used to communicate between controller and corresponding view but this communication is only for a server call, it becomes null if redirect occurs.

So, in short, it’s a mechanism to maintain state between controller and corresponding view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between ViewData, ViewBag and TempData?

A

Both ViewBag and ViewData are used to communicate between the controller and corresponding view but this communication is only for a server call, it becomes null if redirect occurs.

TempData allows us to persisting data for the duration of single subsequent request. It is usually used to stored only one time messages like validation messages, error messages etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is ViewData and when is it used?

A

ViewData is a dictionary object that is derived from ViewDataDictionary class.

ViewData is a property of ControllerBase class.

It is used to pass data from controller to corresponding view.

The data is only available during the current request. If redirection occurs then it’s value becomes null.

Typecasting is required for getting the data and need to check for null values to avoid error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is ViewBag and when is it used?

A

ViewBag is a dynamic property

Basically it is a wrapper around the ViewData.

It is used to pass data from controller to corresponding view.

The data is only available during the current request. If redirection occurs then it’s value becomes null.

It doesn’t required typecasting for getting data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is TempData and when is it used?

A

TempData is a dictionary object that is derived from TempDataDictionary class and is stored in short lives session.

It is used to pass data from the current request to a subsequent request (means redirecting from one page to another).

It’s life is very short and lies only till the target view is fully loaded.

It is usually used to store only one time messages like error messages, validation messages.

Typecasting is required for getting the data and need to check for null values to avoid error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Session and when is it used?

A

Session is a property of the Controller class whose type is HttpSessionStateBase.

It is also used to pass data within the application.

Session is valid for all requests, not for a single redirect.

Typecasting is required for getting the data and need to check for null values to avoid error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly