Mvc: Allow a controller to exist in multiple areas

Created on 9 Aug 2017  路  9Comments  路  Source: aspnet/Mvc

At present a controller may only exist in a single area using the AreaAttribute; it would be good to allow a controller to exist in multiple areas and/or all areas, instead of having to create a Controller that derives from a base class for each area.

3 - Done task

All 9 comments

I don't believe we have any plans to support this, it hasn't been a common request. Usually people dislike the old MVC1-5 behavior where by mistake a controller might end up in multiple areas!

@rynowak thoughts on this?

@Eilon if you could decorate a controller explicitly with multiple areas that would be great, or would it be better to have multiple route for the same controller with a prefix that is the same as a area or a preminant redirect?

@grahamehorner I'll discuss with the team and we'll get back to you.

You can do this btw with a convention. /cc @jbagga - relevant to your work

Ah, if we have a neat snippet of code that does this, I think that's ok for now. This isn't an area (ahem) that we've gotten a lot of feedback on, so a sample might be sufficient in the meantime.

Assigning to @jbagga to come up with a sample (if possible!).

Yep. My hope is that we can make a quick sample and then use it as a test. @jbagga - I'm on the hook to help out with this if you get stuck

Working on a sample

@grahamehorner Here is the sample https://github.com/aspnet/Entropy/tree/dev/samples/Mvc.ControllerForMultipleAreasSample

Closing for now since we have a sample that addresses the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pranavkm picture pranavkm  路  35Comments

mdmoura picture mdmoura  路  33Comments

skyflyer picture skyflyer  路  40Comments

grahamehorner picture grahamehorner  路  52Comments

angelsix picture angelsix  路  61Comments