[PluginController("heading")]
public class MyPluginController : UmbracoApiController
{
// GET: api/SBMSPlugin
public IEnumerable<string> GetAll()
{
return new string[] { "heading1", "heading2" };
}
}
and I have plugin In App_Plugins named Heading
How can I add my web api plugin controller to the plugin package? Do i need to create the controller in app_plugins/heading or I have to do it in Controllers? Where can I find some examples?
Thanks
Yes I've already seen this but if I need to distribute the controller to a client together with the plugin how can I do that? Otherwise what will be the point of plugin based web api if not to be distributed? I don't intend to host it, the client should.
I'm trying to do it. I have created separate project with 1 controller and build a dll. Then in my main project I have added this dll. I've rebuild the initial project. Now I'm trying to call the web api like:
Do you ever figure this out? I think I am having the same problem.
I am trying to create a plugin/package which makes the use of an API or PluginController. So my angular code will http post to my cs.net controller.
I have managed to get this to work by adding the plugin controller in AppCode folder but if I try and move this to my plugin folder within AppPlugins then I get a 404.
I am guessing we need to leave this in the AppCode folder and when we publish the package we do something extra? Or an I on the right track attempting to move this into the AppPlugins?
You can install it and turn it on in the web.config - it will output a list of all of the routes - from that you might be able to determine what the url is.
Otherwise, post your class definition and the attributes, if any you have added to the class and method you are trying to call and maybe we can see what the issue is from that.
I think the question is if the PluginController should be but in the AppPlugins folder or not. As I mentioned I have got this working by putting the controller in the AppCode folder
I think this is the correct setup rather than putting this file in the AppPlugins. I am just looking for confirmation if I am on the right track with this or if I am totally wrong the plugin controllers should in-fact be stored in the AppPlugins. At that point I would have to start figuring out why the route isn't working.
In my case, I have my plugins in a separate project with all of my other code. in my case I have a 3rd project that I targetted model builder to so that the model project is referenced by the umbraco project as well as the project with the controllers and other related logic.
Looking at the docs, it looks to me that you are fine with the c# code in the AppCode folder because it is compiled and executed. The AppPlugins folder generally holds the manifest, and other files that are served to the browser like css, javascript, and html files
I think this is the correct setup rather than putting this file in the AppPlugins. I am just looking for confirmation if I am on the right track with this or if I am totally wrong the plugin controllers should in-fact be stored in the AppPlugins.
This is not at all obvious from the Surface Controller page.
Web Api plugin controller
Hi,
I have a plugin controller
and I have plugin In App_Plugins named Heading
How can I add my web api plugin controller to the plugin package? Do i need to create the controller in app_plugins/heading or I have to do it in Controllers? Where can I find some examples? Thanks
Hi Sonja,
You would be able to call your api with the following url
You can read some more how the routing works : https://our.umbraco.com/documentation/Reference/Routing/WebApi/#plugin-based-controller
Dave
Hi Dave,
Yes I've already seen this but if I need to distribute the controller to a client together with the plugin how can I do that? Otherwise what will be the point of plugin based web api if not to be distributed? I don't intend to host it, the client should.
Thanks
You will need to send them the dll with the compiled code of your controller.
The path will be the same.
Dave
I've not tried this, but you might be able to get it to work in the App_Code folder...
I'm trying to do it. I have created separate project with 1 controller and build a dll. Then in my main project I have added this dll. I've rebuild the initial project. Now I'm trying to call the web api like:
http://myinitialproject.local/umbraco/myplugin/thedllcontroller/functionname but I'm getting 404. Am I missing something?
Hi Sonja,
Do you ever figure this out? I think I am having the same problem.
I am trying to create a plugin/package which makes the use of an API or PluginController. So my angular code will http post to my cs.net controller.
I have managed to get this to work by adding the plugin controller in AppCode folder but if I try and move this to my plugin folder within AppPlugins then I get a 404.
I am guessing we need to leave this in the AppCode folder and when we publish the package we do something extra? Or an I on the right track attempting to move this into the AppPlugins?
Thanks in advanced.
David
There is a nuget package called routedebugger.
You can install it and turn it on in the web.config - it will output a list of all of the routes - from that you might be able to determine what the url is.
Otherwise, post your class definition and the attributes, if any you have added to the class and method you are trying to call and maybe we can see what the issue is from that.
Hi John,
Thanks for your reply.
I think the question is if the PluginController should be but in the AppPlugins folder or not. As I mentioned I have got this working by putting the controller in the AppCode folder
I think this is the correct setup rather than putting this file in the AppPlugins. I am just looking for confirmation if I am on the right track with this or if I am totally wrong the plugin controllers should in-fact be stored in the AppPlugins. At that point I would have to start figuring out why the route isn't working.
In my case, I have my plugins in a separate project with all of my other code. in my case I have a 3rd project that I targetted model builder to so that the model project is referenced by the umbraco project as well as the project with the controllers and other related logic.
Looking at the docs, it looks to me that you are fine with the c# code in the AppCode folder because it is compiled and executed. The AppPlugins folder generally holds the manifest, and other files that are served to the browser like css, javascript, and html files
This is not at all obvious from the Surface Controller page.
is working on a reply...