0

I was just wondering whether its possible to have something like this: I have an Area named Admin and a Controller named 'Edit'. Within this controller I have my Index() which simply lists a bunch of hyperlinks that is treated by the 'Brand' action.

Therefore my url so far is: Admin/Edit/{Brand}.

My question is whether it is possible to have for example: Admin/Edit/{Brand}/Create (as well as edit and delete). This isn't to delete brands, its just to create things within those brands?

I approach that my approach may be misguided and this may necessitate being split into multiple controllers or whatever so don't think that I would like a workaround to make it work this way.

1 Answer 1

3

You could define the following route in your area registration:

context.MapRoute(
    "Admin_default",
    "Admin/{controller}/{brand}/{action}",
    new { action = "Index" }
);

And if you wanted to have other controllers than Edit in this area which have the default route, you could register 2 routes but you will have to define a constraint for the {brand} token or the routing engine won't be able to disambiguate between a brand and a controller action name.

Sign up to request clarification or add additional context in comments.

1 Comment

Its probably worth putting in the answer that this should go underneath my existing MapRoute for Admin/Edit/{brand}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.