ASP.NET MVC Indexes on Index and List

I am developing my first ASP.NET MVC application. This app keeps track of events, users, donors, etc. For a charitable organization. In event controllers, I support standard CRUD operations with new / Edit / Show views (deletion is done with a button on the Show view). But I also want to list all the events.

Is it better to have a List view that you go from Index view, or a List view as an index. The Index view is my default view for the controller. If you keep the index / list separate, what would you specify as the index?

For now, I tend to keep them separate and put the basic reference information in the Index view. Should I consider changing this setting and review the default List view and rename Index to Help?

TIA for collective wisdom SO.

+1


source to share


2 answers


I decided to redirect the index action to the List action. This saves me from having to create and maintain the index view, but leaves open the possibility that I can implement an index action that is other than a list of models.



public ActionResult Index()
{
    return RedirectToAction( "List" );
}

      

+1


source


Your index view page may include

<body>
    <% RenderPartial("List", "Events") %>
</body>

      

which is equivalent to calling



/Views/Events/List.ascx

      

with a list box, which is an asp.net custom mvc control. This will give you an index view that contains a list of events.

0


source







All Articles