How to access My.Resources from a razor view

后端 未结 1 865
无人及你
无人及你 2021-01-17 14:36

I have a razor .vbhtml view and would like to use string resources normally accessible via My.Resources. Seems like I can only get to My.Computer, My.Log and couple other na

相关标签:
1条回答
  • 2021-01-17 14:48

    Add a Messages.resx file to your project. In the properties of this file in the solution explorer set Custom Tool = PublicResXFileCodeGenerator. Now inside the view you can directly access resources:

    @Imports AppName.My.Resources
    
    <div>@Messages.Foo</div>
    

    And here's a screenshot containing all you need:

    enter image description here

    0 讨论(0)
提交回复
热议问题