Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm creating web api, using UmbracoApiController .
I read https://our.umbraco.com/documentation/Reference/Routing/custom-routes and as a beginner I must admit I didn't find it very helpful.
I'll really appreciate step by step instructions how to change the routes from /umbraco/api/controllerName/get?contentN=contentName to /api/v1/controllerName/contentName.
Best , Sandra26
Hi Sandra,
you can't change the routes from the default wired routes to use your custom ones.
What you can do is adding redirect in IIS from your custom url to the default umbraco ones. Via web.config or directly in IIS if you have access.
Or what you can try is to register your custom urls in the RouteTable like it is stated in the docs. For example like this:
RouteTable.Routes.MapHttpRoute( $"distinct route name", url, // url to match new { controller = controllerName, id = UrlParameter.Optional }, new[] {controllerNamespace });
Regards David
Hi David,
I did that. I have problem how to implement FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
public class UmbracoVirtualNodeByNameRouteHandler : UmbracoVirtualNodeRouteHandler { public UmbracoVirtualNodeByNameRouteHandler(string contentName) { } protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext) { } }
}
Because I want go work with content name not with id like in the documentation. Best, Sandra26
Hi Sandra, Did you got it? I'm interested about how you did it!
Quite an old post. But since asked,
In the VirtualNodeRouteHandler, FindContent method is overridden. Name is self explanatory but you need to find your umbraco node here.
I myself use this to grab a dynamic page and place my content in it. So, what I need to do is to find this dynamic page's node.
protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext) { return umbracoContext.ContentCache.GetByXPath($"//{PageNodeAlias}").First(); }
Depending on what you need, you can try to use a similar query to find your content.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to remove umbraco from url , creating custom routes
Hi,
I'm creating web api, using UmbracoApiController .
I read https://our.umbraco.com/documentation/Reference/Routing/custom-routes and as a beginner I must admit I didn't find it very helpful.
I'll really appreciate step by step instructions how to change the routes from /umbraco/api/controllerName/get?contentN=contentName to /api/v1/controllerName/contentName.
Best , Sandra26
Hi Sandra,
you can't change the routes from the default wired routes to use your custom ones.
What you can do is adding redirect in IIS from your custom url to the default umbraco ones. Via web.config or directly in IIS if you have access.
Or what you can try is to register your custom urls in the RouteTable like it is stated in the docs. For example like this:
Regards David
Hi David,
I did that. I have problem how to implement FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
}
Because I want go work with content name not with id like in the documentation. Best, Sandra26
Hi Sandra, Did you got it? I'm interested about how you did it!
Hi,
Quite an old post. But since asked,
In the VirtualNodeRouteHandler, FindContent method is overridden. Name is self explanatory but you need to find your umbraco node here.
I myself use this to grab a dynamic page and place my content in it. So, what I need to do is to find this dynamic page's node.
Depending on what you need, you can try to use a similar query to find your content.
is working on a reply...