How to define route & controller structure for 2 controllers?


How to define route & controller structure for 2 controllers?



I want to create an MVC app to generate factsheets, but I'm not sure how to structure the routing and controllers.

It consists of an index page, which acts as a template for the layout of a number of independent panels, each of which contains different types of data.

I want to have a the route template like the following:

/Factsheets/Panels/PanelType?fundId=1&countryId=ABC 

so these would be the URLs I'm using:

/Factsheets/Panels/NameAndDatePanel?Afund=1&county=IE   /Factsheets/Panels/AssetsPanel?fund=1&county=IE 

I want a Factsheets controller to be able to supply the Panel controller with the configuration object it needs to generate the type of panel I request.

What should my routing structure look like?

What should my controller structure look like?

edit:

What changes if I want to have a roure structure as follows:

I want to have a the route template like the following:

/Factsheets/ContentArea/Panels/PanelType?fundId=1&countryId=ABC 

so these would be the URLs I'm using:

/Factsheets/PageTop/Panels/NameAndDatePanel?Afund=1&county=IE   /Factsheets/PageTop/Panels/AssetsPanel?fund=1&county=IE 

so that FactsheetsController is instantiated to contain the data needed by a ContentArea to know which data to supply to the panel it needs to generate.


return a list of string as JSONResult

1:

What is the best practice for displaying the contents of a DataSet in ASP.net MVC v1.0?
What comes after the ? is the query string so it won't be reflected by the routing engine. How to use TextBoxFor to update the many side of a relationshipSo your route might look like this:. looking for suggestions on how i can highlight areas on an image
routes.MapRoute(     "Default",     "{controller}/{action}/{panelType}",     new { controller = "Factsheets", action = "Panels", panelType = UrlParameter.Optional } ); 
And you would have the following controller:. Wanting to mix server side ASP.Net MVC expansion in javascript file, but how… RenderPartial?
public class FactsheetsController : Controller {     public ActionResult Panels(string panelType)     {         return View();     } } 
UPDATE:. Problem with Primary Key in a Partial View shared by Create and Edit views If the panelType parameter is not optional you could provide a regex constraint:. How to start a new ASP.NET MVC site?
routes.MapRoute(     "Default",     "Factsheets/Panels/{panelType}",     new { controller = "Factsheets", action = "Panels", panelType = UrlParameter.Optional },     new { panelType = ".+" } ); 
How can I determine the current controller action in an mvc sitemap?

39 out of 100 based on 39 user ratings 519 reviews

@