Bitz Bitz - 11 months ago 45
C# Question

How do I create this route and use it?

Currently I am using the default route but I need a route that works like this:


Where index add and delete are views with controllers in the AdminController.cs

The current structure everywhere else is fine, as it doesn't require multiple subdirectories.

Currently I have the the file I need to start with in:


How would I create this route and how do I apply it to the controller?

Am I approaching this incorrectly?

Answer Source

This can be easily resolved using Route attributes, like:

public ActionResult TestView(int id)
    if (!String.IsNullOrEmpty(id))
        return View(“OneUser”, GetUser(id));
    return View(“AlUsers”, GetUsers());