I think the issue you are running into is that from your Surface Controller you are likely returning a partial view, not a view, from where you can't use sections. That link appears to suggest some ways around it, but can't say I've tried any. I think you would just need to add the @section tag the scripts to your view (template) rather than the partial view you are returning from your controller.
How to render sections from a SurfaceController view
My _layout.cs template contains the following code:
How can I inject some code into that section from within a surface controller view? In MVC I would do:
I know this is probably not the right route, but please advise an alternative method. thank you in advance.
I think the issue you are running into is that from your Surface Controller you are likely returning a partial view, not a view, from where you can't use sections. That link appears to suggest some ways around it, but can't say I've tried any. I think you would just need to add the @section tag the scripts to your view (template) rather than the partial view you are returning from your controller.
Andy
is working on a reply...