November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Checked that the site URLs and host names are setup correctly in Admin mode?
Is this Page browseable? This usually happens if you only created the Model and the Controller for the Page Type but no view associated with it.
Hi Johan,
I do the same what you advise, But still, I got the null response.
Actually, I have a separate service project in which I can't get the URL.
The main project has contains the controllers and views, there the URL resolver.geturl() workes fine.
Is this necessary to have the views and controllers for getting the Url in my separate project. or
Is there any api is available to get the Url, without using controllers and views.
I tried, Urlhelper and UrlResolver but both gave null responce.
hi,
it shouldn't require mvc type project (where views and controllers are) to get link of the content. in what context are you calling GetUrl()? is it episerver scheduled job or during just a normal web request (controller calls service lib to do the work)?
Thanks, Valdis.
I am trying to use it inside the APIController(AJAX call).
Adding to that, While including the Controllers and views it works well, When excluding it, returns null.
In my case without controllers and views can we get the URL?
Kindly suggest and advise.
hi,
it will NOT work in api controller out of the box. as api controller is called "directly" getting or posting to the api endpoint. in order for the episerver to resolve whole context, request needs to be "normal" - like accessing episerver page (then epi kicks in and setups whole execution context including all routing stuff and such).
if you could describe a bit more in details the usage scenario (how and why you need to get content url) we could figure out what would be the best way to get that url.
i've implemented in back in days that client side is passing in content id from back to the api controller (like episerver page itself generates content id in markup and clientside takes it and passes back to api controller). then used content repositopry to fetch the page. sounds hacky, but that's one of the ways how to "restore" epi context in non-epi request.
Hi Valdis,
Thank you very much for your advice.
Actually, I try to get the URL of the page data.
By using content id I just build the URL directly without using API.
Thank you.:)
Hi,
I am using two web projects in a single solution, the Urlresolver.geturl() returns the URL for one web project but in another project, it returns null.
I tried in follwing ways,
urlResolver.GetUrl(ContentReference contentLink)
urlResolver.GetUrl(IContent content)
urlResolver.GetUrl(ContentReference contentLink, string language)
But I got null.
How to resolve this.