locked
How to determine browser culture with aspNetCore2.0? RRS feed

  • Question

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

    var languages = HttpContext.Request.UserLanguages;

    Since the above is not supported with .NET Core 2 I tested with:

    var requestContext = Request.HttpContext.Features.Get<IRequestCultureFeature>();

    However, it returns null. What is the correct way or alternative to get the language? i have set it to norweigian in browser.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (kokkisajee) or Facebook (sajeetharan) profile for Sajeetharan at Stack Overflow, Q&A for professional and enthusiast programmers

    • Moved by CoolDadTx Wednesday, March 21, 2018 2:13 PM ASP.NET related
    Wednesday, March 21, 2018 4:32 AM

All replies

  • Hello Sajeetharen,

    Check out the following resource ASP.NET Core Localization culture, under "Determine Request Culture" section.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, March 21, 2018 10:02 AM
  • https://forums.asp.net/1255.aspx/1?ASP+NET+Core

    It's where you can post about your issue.

    Wednesday, March 21, 2018 10:08 AM