Models, Views, and Controllers

What does MVC look like?

MVC look like
All Posts MVC look like

URL Patterns

Result Type

for detail check this link

MVC Applications

•Models encapsulate objects and data
•Views generate the user interface
•Controllers interact with user actions
•Code in .cshtml and .cs files
–Dynamic object for storing basic pieces of information
•Alias for ViewData
–Perfect for sending messages to the view
–Only available for that action
•Redirects cause the ViewBag to be emptied
–Just like the ViewBag, but it’s also available on the next page
We can save date

like this


here “myobj” is the keyword in the deictionary and the object it is holding
against it is myobj and receive it like this in view

var auction = (mvcauction.models.myobj)ViewData[“myobj”]

it is receiving it not as a strongly typed object in fact as a object type and has to caste it in view we can use viewbag method to avoid it and receive object as  strongly typed object
like this

var myobj=viewbag.myobj

we can use better method by passing model like
return view(myobj);

var myobj=Model

MVC is a stateless architecture if u need to redirect user to another
request/action and giving him message of successful completion
tempdata is both exposed to controller and view tempdata is stored on server for exactly one request from the user if u assign data to it on one request it would be available to very next request

Action Name