I am learning .NET MVC and an app I'm building has become rather spaghetti-like. In my code I have many actions in different controllers which naturally all produce various views and partialviews. To make matters worse, I have @Html.Action commands which add another layer of confusion. Some of this is left over from the default scaffolding action.
Is there any tool that produces a list of all the possible routes in my site and the views they return?
I'd also like to find all the unused views and actions without views and generally refactor everything properly. Something like this (please don't comment on this specific example):
Route Views returned
------------------------------------------
/User/Edit /User/Edit.cshtml
/Admin/User/Edit /User/Edit.cshtml
...
Does such a thing exist? Can it be done with a .tt template?
Or perhaps my whole approach is wrong..!
The @model directive allows access to the list of movies that the controller passed to the view by using a Model object that's strongly typed. For example, in the Index.cshtml view, the code loops through the movies with a foreach statement over the strongly typed Model object: CSHTML Copy.
When an MVC application first starts, the Application_Start() method is called. This method, in turn, calls the RegisterRoutes() method. The RegisterRoutes() method creates the route table. The default route table contains a single route (named Default).
Where is RouteTable stored in MVC? RouteTable is a collection of routes that is stored in RouteConfig. cs file in App_Start folder of the application.
Routing in ASP.NET MVC cs file in App_Start Folder, You can define Routes in that file, By default route is: Home controller - Index Method. routes. MapRoute has attributes like name, url and defaults like controller name, action and id (optional).
These maybe can help you on your way:
I haven't tested the Mvc Route Visualizer, but it seems like it could do what you ask.
Edit:
Maybe this works better for you. It won't show you the views returned, though, it will at least display all controllers and actions:
After routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
, add these lines of code:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// If you don't have "HomeController", choose another controller you have.
// MvcCodeRouting will look for all controllers in the same namespace and sub-namespaces as the one specified here.
routes.MapCodeRoutes(typeof(HomeController), new CodeRoutingSettings
{
UseImplicitIdToken = true
});
// Other, existing, routes here...
Build and run the application.
If you have installed Route Debugger, you can see them there to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With