Get browser language in .AspNetCore2.0?

后端 未结 4 1169
渐次进展
渐次进展 2021-02-19 08:16

I am trying to get the default language from the browser and I use the following code to get it:

var languages = HttpContext.Request.UserLanguages;
4条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 09:06

    You have to add the localization middleware to enable parsing of the culture header, and then get the value through IRequestCultureFeature.

    Check this link : https://github.com/aspnet/Mvc/issues/3549

提交回复
热议问题