How to get Current Published Content in Middleware.
Hello everybody,
When a user get in the a page I get the first culture of the browser and then what I want is to redirect the specific page to culture of browser.
So, I use the following middleware to do this.
Can you suggest me a way to get the PublishedContent so I will be able to find the url of different culture?
Or, is there another way to get all urls by language of the current page?
How to get Current Published Content in Middleware.
Hello everybody,
When a user get in the a page I get the first culture of the browser and then what I want is to redirect the specific page to culture of browser. So, I use the following middleware to do this.
but the Current Page is always null.
Can you suggest me a way to get the PublishedContent so I will be able to find the url of different culture? Or, is there another way to get all urls by language of the current page?
Thanks a lot
I think you need to do this
Hi Huw. Thanks a lot for your reply.
I try to find the IPublishedContent by the Url Address
so I try this:
which helps, but not in all cases.
So, I try to find the IPublishedContent by urlAlias (variable UrlAddress)
Any suggestion of how to achieve this?
you should be able to use
where url = "/some-page/sub-page/"
You are right. Because my site is multilanguage I used the url = "/el/some-page/" instead of url = "/some-page/"
In case, someone want to use this approach the code is:
The middleware class:
public class SetUserLanguageOnStartupMiddleware {
}
Extension for IApplication:
and in Startup.cs
before app.UseUmbraco()
is working on a reply...