This project is read-only.

Accessing webapi URL

Topics: Customizing Orchard, General, Writing modules
Sep 9, 2014 at 9:18 PM
If this is not supported in orchard I would say its at least a needed feature or maybe a bug.

In mvc I can get a url to a web api by doing something like the following in razor.

@Url.RouteUrl("DefaultApi", new { httproute=true, controller="Albums", id=3})
@Url.HttpRouteUrl("DefaultApi", new { controller="Albumns", id=3 })

I am unable to find the route names of webapi's in orchard. When I overload the routes and give them names they do not work either.

This is important for when I want my client side code to talk to a web api using ajax. Maybe this is not a problem and no one is paying attention to this discussion thread but I will submit this as an issue if no one knows how to do this.
Sep 11, 2014 at 8:52 PM
The default (i.e. the ones that are generated for every module and are api/controller/id) routes don't have names so this won't work. Probably they should have names for such scenario; please open a bug report.

Otherwise named routes should work as expected, can you share the code of the route provider where you create named routes?
Sep 11, 2014 at 9:06 PM
I will open an issue for this, lets get default ones working first then see about custom routes.