Attribute Based Routing and Ordering

I am using ASP.NET MVC 5 in ASP.NET 4.5 on .NET 4.6.1.

I have two controllers:

FooController
FooIndexController

This is because index actions for Fooare complex, so I felt better when they were in their own classes Controller.

I use attribute based routing. My version of ASP.NET MVC has a property Orderon RouteAttribute.

I have the following actions:

class FooController {

    // Returns a view to allow editing of the Foo entity
    [HttpGet]
    [Route("~/{tenant}/foo/{fooName}", Order=2)]
    public ActionResult Edit(String fooName, FooViewModel model) {
        ...
    }

}

class FooIndexController {

    // Returns a CSV file download listing all of the Foo entities
    [HttpPost]
    [Route("~/{tenant}/foo/csv", Order=1)]
    public ActionResult IndexCsv() {
        ...
    }
}

So, as long as the resource path bar/foo/csvmatches both route patterns, I pointed out the Order=1action explicitly IndexCsvso that it matches this action path and is executed with it, however I still get this yellow -screen-from-death color:

, URL. , URL.

:     MyProject.FooController     MyProject.FooIndexController

Order?

[RoutePrefix] .

UPDATE

Phil Haack Routing Debugger, , , POST bar/foo/csv , n/a {*catchall}, GET bar/foo/123 Edit ( ). , ​​ .

UPDATE2

/ . 100% , .

+4

Source: https://habr.com/ru/post/1661044/


All Articles