View: It contains the layout page. Before any view is rendered, viewstart page is rendered. View might have markup tags like body, html, head, title, meta etc. View is not lightweight as compare to Partial View. Partial View: It does not contain the layout page. Partial view does not verify for a viewstart.cshtml.We cannot put common code for a partial view within the viewStart.cshtml.page. Partial view is designed specially to render within the view and just because of that it does not consist any mark up. We can pass a regular view to the RenderPartial method.
There are total nine return types we can use to return results from controller to view. The base type of all these result types is ActionResult. ViewResult (View) : This return type is used to return a webpage from an action method. PartialviewResult (Partialview) : This return type is used to send a part of a view which will be rendered in another view. RedirectResult (Redirect) : This return type is used to redirect to any other controller and action method depending on the URL. RedirectToRouteResult (RedirectToAction, RedirectToRoute): This return type is used when we want to redirect to any other action method. ContentResult (Content) : This return type is used to return HTTP content type like text/plain as the result of the action. jsonResult (json): This return type is used when we want to return a JSON message. javascriptResult (javascript): This return type is used to return JavaScript code that will run in browser. FileResult (File): ...
Routing is a mechanism to process the incoming url that is more descriptive and give desired response. In this case, URL is not mapped to specific files or folder as was the case of earlier days web sites. There are two types of routing (after the introduction of ASP.NET MVC 5). Convention based routing: to define this type of routing, we call MapRoute method and set its unique name, url pattern and specify some default values. Attribute based routing: to define this type of routing, we specify the Route attribute in the action method of the controller. Routing is the URL pattern that is mappped together to a handler,rounting is responsible for incoming browser request for particular MVC controller. In other ways let us say routing help you to define a URL structure and map the URL with controller. There are three segments for routing that are important, ControllerName ActionMethodName Parammeter i.e: ControllerName/ActionMethodName/{ParamerName} and als...
Comments
Post a Comment