You must Sign In to post a response.
  • Category: ASP.Net MVC

    How to Use Local Resources in MVC5

    I am new in MVC.
    Anyone please tell me how to use local resources in MVC5.
    It should be use in model, view as well as controller as per the requirement.
    I want to create separate resources according to views.
    Please help.
  • #768038

    Are you looking for localization with ASP.NET MVC? Correct me if I am wrong.
    For making that we create a folder under the project and start adding the class files into that folder.
    Then I will start creating all the controller or model or view files with the same name.

    e-g inside Local Folder if class is created as Local.Class then controller will be LocalController and View will be Local.cshtml


  • #768046
    i have one website name.
    You refer this website you surely can understanding.
    in this website your answer will show clearly into step by step.
    website name:

    hope this help you

    thank you

  • #768064
    Hai Pranjal,
    You can create separate resource file(.resx) and then you can retrieve the resource value based on the class name as well as the culture name to your view to display.

    using System.Resources;

    string titleValue = MyResource.ResourceManager.GetString(title);

    You can also follow below link for more details:

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #768127
    You should not use App_GlobalResources or App_LocalResources with MVC. That is because of the way these resources work. These resources are not embedded in your project, but are instead compiled by the ASP.NET runtime. This means that your resources will not be available when not running inside the ASP.NET runtime, which means you would lose the ability to unit test your views and controllers if you use resources in them.
    Instead, you should use the approach you mention yourself in your question. Put your resource whereever you want, and set it to 'Embedded resource' and the custom tool should be 'PublicResXFileCodeGenerator'.

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • Sign In to post your comments