Comments (3)
You'd have to fix up the controller convention to instantiate the right controller.
Areas in MVC are kinda broken though, they were bolted on later so they're a bit funny to get to work outside of the default scenario.
from contosouniversity.
Thanks. I figured out that I need to modify the ControllerFactory, but figuring out the routing for the Areas is where I'm currently stuck, albeit, I haven't spent too much time at it yet. When I have a little more time, I'll take another crack at it.
from contosouniversity.
I got this working. I adding the following area location formats to the FeatureViewLocationRazorViewEngine class constructor
this.AreaViewLocationFormats =
this.AreaMasterLocationFormats =
this.AreaPartialViewLocationFormats = new[]
{
"~/Areas/{2}/Features/{1}/{0}.cshtml",
"~/Areas/{2}/Features/{1}/{0}.vbhtml",
"~/Areas/{2}/Features/Shared/{0}.cshtml",
"~/Areas/{2}/Features/Shared/{0}.vbhtml",
};
and modified the ControllerFactory.GetControllerType method like so
protected override Type GetControllerType(RequestContext requestContext, string controllerName)
{
var tokens = requestContext.RouteData.DataTokens;
var areaName = tokens["area"] as string;
var areaNamespace = !String.IsNullOrEmpty(areaName) ? "Areas." + areaName + "." : String.Empty;
var controllerTypeTemplate = "ContosoUniversity.{1}Features.{0}.UiController";
var controllerType = String.Format(controllerTypeTemplate, controllerName, areaNamespace);
return typeof(ControllerFactory).Assembly.GetType(controllerType);
}
No change was needed for the Area Registration class, which was a pleasant surprise.
from contosouniversity.
Related Issues (20)
- How would you implement authorization business logic? HOT 1
- Use of Attribute Routing possible? HOT 4
- Autofac? HOT 4
- FormBlocks HOT 1
- Dispatching messages from command handler after committing DB transaction HOT 1
- Use AutoFac instead of StructureMap HOT 7
- HtmlTags v4 support HOT 3
- Unable to create instructor HOT 2
- RedirectToActionJson HOT 1
- Add .vs folder to gitignore
- using roundhouse; error after yesterday update
- Basic DropDownList HOT 4
- Why is MvcTransactionFilter related to SchoolContext ? HOT 5
- Unable to add a new department
- ASP.NET Core HOT 1
- Should features own the domain model as well? HOT 1
- Generic Notifications HOT 3
- Question: indexer on foreach HOT 1
- FxCop CA1034 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contosouniversity.