Not all these services are available immediately in the view.
You may need to inject them in your view with dependency injection. You'd need to add a line similar to this inside your razor view:
For the request, you should check if you can access the request through HttpContext instead like this:
HttpContext.Request
If that doesn't work, you can inject the IHttpContextAccessor, just like the PublishedUrlProvider
A quick google search about the content query didn't yield any results for me, I can't help you with that unfortunately. It may have been removed from the umbraco helper or the name may have changed.
Umbraco 8 search to Umbraco 9
Hi,
I had this search page in Umbraco 8 and tried to move it over to Umbraco 9 but doesn't seem to be working.
I get the following error when trying to run it in umbraco 9
Any one able to help or advise on why this isnt working?
Thanks
Hi there!
Not all these services are available immediately in the view. You may need to inject them in your view with dependency injection. You'd need to add a line similar to this inside your razor view:
For the request, you should check if you can access the request through HttpContext instead like this:
If that doesn't work, you can inject the
IHttpContextAccessor
, just like the PublishedUrlProviderA quick google search about the content query didn't yield any results for me, I can't help you with that unfortunately. It may have been removed from the umbraco helper or the name may have changed.
As I was trying to figure this out myself I came across this:
var results = _publishedContentQuery.Search(@searchQuery, string.Empty);
Seems the Umbraco Helper has been removed.
This is the code that works for me for a simple search in Umbraco 9.
In my "search results" template's code:
I followed this:
https://our.umbraco.com/documentation/reference/querying/IPublishedContentQuery/
is working on a reply...