'GlobalSettings' does not contain a definition for 'UmbracoMvcArea'
Hi,
I am trying to use an MVC controller for my package and I am following the documentation using GlobalSettings.UmbracoMvcArea but I get the error in the subject.
I have added all of the using statements that Visual Studio was asking for. The code in the example is:
GlobalSettings is marked as internal in the core and so you cannot access the UmbracoMvcArea property to add your custom route.
Also when you have right clicked and resolved your GlobalSettings class, it has found an older GlobalSetting class that is public from the older (lowercase u) umbraco namespace, and this does not contain the UmbracoMvcArea property which is why you are getting the specific error message.
If you read the umbracoPath property from the web.config this should I think give the correct location of the /umbraco folder to map your custom mvc route in the backoffice:
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext
applicationContext)
{
var umbracoPath = System.Configuration.ConfigurationManager.AppSettings["umbracoPath"];
if (umbracoPath.StartsWith(SystemDirectories.Root)) // beware of TrimStart, see U4-2518
umbracoPath = umbracoPath.Substring(SystemDirectories.Root.Length);
umbracoPath = umbracoPath.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
RouteTable.Routes.MapRoute(
name: "cats",
url: umbracoPath + "/backoffice/cats/{action}/{id}",
defaults: new
{
controller = "Cats",
action = "Meow",
id = UrlParameter.Optional
});
}
Note it needs to have it's ~ and leading / removed...
When working with data in the backoffice, I tend to use an UmbracoAuthorizedJsonController or UmbracoAuthorizedApiController (as these are routed by convention) to expose data via Web Api endpoints, that I then consume in AngularJs, rather than creating an actual MVC controller for the backoffice, but I'm not sure what you are up to!! but the above should enable you to map the route correctly!
'GlobalSettings' does not contain a definition for 'UmbracoMvcArea'
Hi,
I am trying to use an MVC controller for my package and I am following the documentation using GlobalSettings.UmbracoMvcArea but I get the error in the subject.
I have added all of the using statements that Visual Studio was asking for. The code in the example is:
Hi James
The documentation is out of date :-(
GlobalSettings is marked as internal in the core and so you cannot access the UmbracoMvcArea property to add your custom route.
Also when you have right clicked and resolved your GlobalSettings class, it has found an older GlobalSetting class that is public from the older (lowercase u) umbraco namespace, and this does not contain the UmbracoMvcArea property which is why you are getting the specific error message.
If you read the umbracoPath property from the web.config this should I think give the correct location of the /umbraco folder to map your custom mvc route in the backoffice:
Note it needs to have it's ~ and leading / removed...
When working with data in the backoffice, I tend to use an UmbracoAuthorizedJsonController or UmbracoAuthorizedApiController (as these are routed by convention) to expose data via Web Api endpoints, that I then consume in AngularJs, rather than creating an actual MVC controller for the backoffice, but I'm not sure what you are up to!! but the above should enable you to map the route correctly!
regards
Marc
Hi Marc,
Thanks for the reply, I will give it a go today.
Hi James
If that's all good, I'll put in a pull request to update the documentation!
regards
Marc
Hi Marc,
That did work thanks!
is working on a reply...