Skip to main content

Posts

How to pass data from action to action and action to view.

ViewBag:- Is similar kind of dynamic variable in c#.  Dynamic internally uses reflection and at runtime, it finds out what the data or property.By using viewbag on that you can define dynamic property and it creates a dynamic property on the fly also they cannot provide compile error. ViewBag.dynamicPropertyName=”something”; ViewBag uses dynamic features that are added in c# 4.0 version.which allows dynamically add property. It is used to pass data from a controller to view.Internally view bag properties are stored name-value pairs in viewdata dictionary. ViewData:- Is a dictionary of objects that are stored and retrieved using as key ViewData[‘keyname’]=”something”; Both ViewBag and ViewData does not provide compile time error checking.You know error at runtime only.It is good practice to use strongly typed view models. Because strongly typed view models provide compile time error checking. TempData:- Tempdata is used for passing data from controller to cont...
Recent posts

Routing In MVC

Routing - Is used to simplify MVC URLs. Mapping User-friendly URLs to action names in the controller. Default be the last statement bcoz else it bypasses the other urls from the route which you defined. It is a collection and has unique names or key in the collection. How to start page in MVC- in MVC there is no start page bcoz the first hit always comes to the controller. For that, you have to set start controller and start the action and in routing, you have to set nothing means it serves as the start page. Ignoreroute - it not allows a user to download config or axd files.

Basic Hello World Program In MVC

MVC - Model View Controller is an architectural pattern where we divide our solution into 3 layers model view and controller. Every layer has unique functionality and the whole MVC depend on convention over configuration . The first hit always comes to the Controller and from their, it searches for required view and model. In ASP.NET web form application, the URLs are mapped to physical files wherein MVC URL is mapped to controllers and controller action methods .