Think this has been updated for RC001 to use IOptions pattern...
You can assign a default RenderController to be a custom implementation by updating the options for UmbracoRenderingDefaultsOptions in the ConfigureServices method in the Startup.cs class.
First of all you have to create your own controller. Your custom implementation of RenderController should either inherit from the core RenderController as in the examples above or implement the IRenderController interface.
Once you've created your controller then you now use
the DefaultRenderController extension method in the ConfigureServices method in the Startup.cs class. (call SetDefaultRenderController method after the AddWebsite method)
Thanks for taking the time to explaining this IOptions pattern.
Using services.Configure<>() as you describe solves my problem.
I found one difference, though: it looks like the .SetDefaultRenderController() extension you mention does not exist in v9.0.0-rc001 ...nor it is required, because the solution works without that line - just using services.Configure<>() does the trick and sets the default render controller.
A google search for the missing method got me to this discussion which seems to confirm the fact that the method is not required.
Can you please clarify that point before I mark your response as the solution?
Yes you are correct SetDefaultRenderController() is no longer required...
In the eagerness to document things! the SetDefaultRenderController() extension method got added to some draft documentation, but then got switched to IOptions approach - which we then updated, but didn't take out the extension method!!!
I'll update the docs page accordingly.
But hopefully that aleviates your immediate concerns!
How to change Default Controller Type in V9
In Umbraco v9 beta versions there was a way to override the default controller type by issuing:
But the IUmbracoRenderingDefaults interface is gone in rc-001 and I can't find the correct way to override the default controller type.
Thanks in advance.
Hi Jose
Think this has been updated for RC001 to use IOptions pattern...
You can assign a default RenderController to be a custom implementation by updating the options for
UmbracoRenderingDefaultsOptions
in theConfigureServices
method in the Startup.cs class.First of all you have to create your own controller. Your custom implementation of RenderController should either inherit from the core RenderController as in the examples above or implement the IRenderController interface.
Once you've created your controller then you now use the DefaultRenderController extension method in the ConfigureServices method in the Startup.cs class. (call SetDefaultRenderController method after the AddWebsite method)
Hi Marc,
Thanks for taking the time to explaining this
IOptions
pattern. Usingservices.Configure<>()
as you describe solves my problem.I found one difference, though: it looks like the
.SetDefaultRenderController()
extension you mention does not exist in v9.0.0-rc001 ...nor it is required, because the solution works without that line - just usingservices.Configure<>()
does the trick and sets the default render controller.A google search for the missing method got me to this discussion which seems to confirm the fact that the method is not required.
Can you please clarify that point before I mark your response as the solution?
Thanks again!
Hi Jose
Thanks for trying it out and reporting back!
Yes you are correct SetDefaultRenderController() is no longer required...
In the eagerness to document things! the SetDefaultRenderController() extension method got added to some draft documentation, but then got switched to IOptions approach - which we then updated, but didn't take out the extension method!!!
I'll update the docs page accordingly.
But hopefully that aleviates your immediate concerns!
thanks
Marc
Ok updated docs here:
https://our.umbraco.com/Documentation/Reference/Routing/custom-controllers-v9
:) Thanks
Docs are now here: https://our.umbraco.com/documentation/reference/routing/custom-controllers#replace-umbracos-default-rendercontroller :)
is working on a reply...