문제

Is there a way for a the display Url for a certain content item in an ApiController? In a regular MVC Controller I can do

Url.ItemDisplayUrl(item)

I want to be able to do something similar from an ApiController.

도움이 되었습니까?

해결책 2

You can create an instance of System.Web.Mvc.UrlHelper (the type of the Url property in a regular MVC controller) using

var myUrlHelper = new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext);

If you add using Orchard.Mvc.Html; to the top, you can do

myUrlHelper.ItemDisplayUrl(item);

다른 팁

If you take a look at ContentItemExtensions you will see that the url is retrieved from the metadata. If you're using AutoroutePart you can get it from there too.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top