Sunday, April 10, 2016

Html.RenderAction Vs Html.Action

Both Html.RenderAction and Html.Action can be used to call an Action method and render output of the action method as embedded content in the main view, they can be used to display content in a part of the main view page like user controls.

In this post we shall see the difference between these and the scenarios where to use each of these.

Asp.net MVC 2 Url.Action example

Asp.Net MVC offers 2 ways of adding Hyperlinks in a page.

1. Using the Html.ActionLink method
2. Using the Url.Action method

In this post we shall see on how to add Hyperliks to a View page using Url.Action. The Url.Action just returns the URL for the specified controller and action, hence while using the Url.Action method we need to explicitly form the tags and text around the Hyperlink as follows.

Asp.net MVC 2 Html.ActionLink example

Asp.Net MVC offers 2 ways of adding Hyperlinks in a page.

1. Using the Html.ActionLink method
2. Using the Url.Action method

In this post we shall see on how to add Hyperliks to a View page using Html.ActionLink. The Html.ActionLink method generates an  <a href=””> tag and places in the page.

The simplest form of Html.ActionLink, takes the Link Name and the Action Method name and the Controller name as parameters, if the controller name is not provided it takes the Home controller

Html.ActionLink and Url.Action in an Asp.Net MVC 2

Hyperlinks are a common requirement in any webpage, in general we use the <a href> tag to create hyperlinks from one page to another, Asp.Net MVC still allows this type of hyperlinks in addition it provides 2 other ways of adding Hyperlinks in a page.

Asp.Net MVC Set Startup Page

In Asp.Net Web Farms we set the startup page by just right clicking the page and selecting Set as Startup Page, however in Asp.Net MVC Applications we need to set this in the Global.asax.cs file. In this post we shall see on how to configure the default start up page for an Asp.Net MVC Application.