ViewResult Class
The ViewResult class implements the abstract ViewResultBase class and is used to render a view.
By default, ASP.NET MVC checks first in
Examples:
1)
public ActionResult Index()
2) Passs data to View using Model
public ActionResult Index()
By default, ASP.NET MVC checks first in
\Views\[Controller_Dir]\
, but after that, if it doesn't find the view, it checks in \Views\Shared
.Examples:
1)
public ActionResult Index()
{
return View();
}
2) Passs data to View using Model
public ActionResult Index()
{ return View("NameOfView", Model); }
3)
public ActionResult Index()
{ return View("NameOfView"); }
4) Passs data to View using ViewData
public ActionResult Index() { ViewData["somedata"] = "%43***&FGTRRR"; return View(); }
5) Display a view from another controller
public ActionResult Index() { return View("~/Views/ControllerName/NameOfView") }
Labels: ActionResult, ViewResult
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home