Conventional Controller


Conventional Controller

Published on Sun 16 Dec 2007 12:12 ( 2 years, 2 months ago)
ASP.NET Learning notes

ASP.NET MVC action method we need to call RenderView("viewname"), ASP.NET MVC will look the viewname.aspx under "view/action/" and "view/shared".  In Ruby On Rails, this step is not required, Rails will try to find same name view under view directory. 

Can we do that in ASP.NET MVC, Phil Haack has done this:

http://haacked.com/archive/2007/12/09/extending-asp.net-mvc-to-add-conventions.aspx

So instead of writing your controller like this:

public class HomeController : Controller
{
[ControllerAction]
public void Index()
{
//Your action logic
RenderView("Index");
}
}

Using my class you could write it like this

public class HomeController : ConventionController
{
public void Index()
{
//Your action logic
}
}


Related posts:


Search related in web:

Custom Search

RSS Feed

One click subscribe this blog in your google reader!

Be social!


Want to say something here? please sign in



Blog posts link to this page
What are friends tweeting?
Tags cloud
Monthly Archives