开发者

enum classes MVC calling from controller

开发者 https://www.devze.com 2022-12-25 12:42 出处:网络
if i create my enum class in the global.ascx in MVC, is there a way i can call that class from a controller.

if i create my enum class in the global.ascx in MVC, is there a way i can call that class from a controller.

ie

i do this in my global.ascx class volume myVolume = volume.Low

is there a开发者_高级运维 way i can find out what i set myVolume to from a controller.


Scope of variables check that it is accessable, then use

MvcApplication.MyEnumProperty = MvcApplication.EnumType.EnumValue

Note: its a standard class so the property will need to be defined as static or you could wrap in a singleton, your call, so that all controllers can reach it. Session might be a better place to store the value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号