How to access global resources in a view using asp.net mvc razor

我们两清 提交于 2019-12-03 04:52:26

Try this,

@Resources.General.Hello

syntax: Resources.[ResourceName].[Property]

you need to refer to your namespace:

@GeneralResxNamespace.General.Hello

You can do this in an easier way by adding namespace to /Views/Web.config file In section with namespaces add section below:

<add namespace="*YourProjectNamespace*.*ResourcesNamespace*.Resources" />

Then you can use resources without namespace, like in the example:

General.Hello

To access value from resoure file in view

Add this name space

@using System

Then display the value like this

@ResourceFile.Address  (ResouceFile is the name of the ResouceFile)

This method is used when evironment culture thread is used.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!