I have created an MVC Partial View using SurfaceController. It works well. But I want to insert it in a Gird.
My Questions:
I think I should create a macro then call that controller action using Html.Action and then insert the macro into grid. I just wondering if this way is correct and best practice.
Also when I tried to do that, I was unsuccessful as I always receive Error loading Partial View script. If this way is correct, I really appreciate it if you show me an example or tutorial.
You could definitely insert your partial through a macro, I think that's a good solution when you need it in RTE/Grid.
About your error, that's a generic error message that always shows when a macros fails, so that it won't expose sensitive info. The complete error message can be found in the log file, check /App_Data/Logs. (My guess is a missing namespace.)
Best of luck to you, let me know if you need anything else!!
You were right, Eventually I created my first macro using MVC.
Now I faced another issue. When I create a local surfacecontroller it works well. Then I created a new directory in App_Plugins and added Views and MacroPartials and added my view to this views folder. It works properly but if I add PluginController attribute, it gives this error: No route in the route table matches the supplied values.
Just wondering, I want to use that plugin, on Macro using @Html.Action("Index","Search")
Should I change anything when I convert SearchController to Plugin?
MVC Partial View and Macro
I have created an MVC Partial View using SurfaceController. It works well. But I want to insert it in a Gird.
My Questions:
I think I should create a macro then call that controller action using Html.Action and then insert the macro into grid. I just wondering if this way is correct and best practice.
Also when I tried to do that, I was unsuccessful as I always receive Error loading Partial View script. If this way is correct, I really appreciate it if you show me an example or tutorial.
Hi Mehrdad!
You could definitely insert your partial through a macro, I think that's a good solution when you need it in RTE/Grid.
About your error, that's a generic error message that always shows when a macros fails, so that it won't expose sensitive info. The complete error message can be found in the log file, check /App_Data/Logs. (My guess is a missing namespace.)
Best of luck to you, let me know if you need anything else!!
Thanks Dennis,
You were right, Eventually I created my first macro using MVC. Now I faced another issue. When I create a local surfacecontroller it works well. Then I created a new directory in App_Plugins and added Views and MacroPartials and added my view to this views folder. It works properly but if I add PluginController attribute, it gives this error: No route in the route table matches the supplied values.
Thanks again for your help.
Strange. Did you do as explained on this page: https://our.umbraco.org/documentation/reference/routing/surface-controllers (Bottom part "Plugin based controllers")
Could it be that you have to restart the app-pool so that all routes are re-routed?
Also you are awear that when you make a surfacecontroller to a plugin controller the URL changes?
Without the Plugincontroller attributre:
With the plugincontroller attribute:
Thanks Dennis,
Just wondering, I want to use that plugin, on Macro using @Html.Action("Index","Search") Should I change anything when I convert SearchController to Plugin?
Yes you can call it like that but you have to specify your area name i.e the name you´ve given your plugin.
if you used this this attribute for the surfacecontroller:
Thanks Dennis,
You are expert. All your responses helped me too much.
Hi Mehrdad!
Awsome, glad to hear that it worked out for you. Good luck with the rest of your plugin!! Have a great day!! :)
is working on a reply...