Prog
Prog

Reputation: 41

How to route Mvc Controller action when there is subdirectory?

This type of url works: ABC/CSDS?id=314

Folder Structure:

Controllers - Folder ,ABCController - Class ,CSDS = Action

Global.cs file has:

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "ABC", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

How to make change for subdirectory url like

ABC/TESTN/CSDS?id=314 to go to

Controllers - Folder ,ABCController - Class ,CSDS = Action

Currently it says "The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable"

Upvotes: 0

Views: 495

Answers (1)

SoManyGoblins
SoManyGoblins

Reputation: 5927

How about adding a rule like this:

routes.MapRoute(
            "Default", // Route name
            "{controller}/TESTN/{action}/{id}", // URL with parameters
            new { controller = "ABC", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

Warning, not tested, I don't have the tools installed at work :(

Upvotes: 3

Related Questions