use a global setting as an attribute argument

前端 未结 1 938
日久生厌
日久生厌 2021-01-19 04:41

I want to specify an argument in an attribute, like this:

[OutputCache(Duration = GlobalSettings.GlobalVar)]

Where GlobalVar is a variable

相关标签:
1条回答
  • 2021-01-19 05:01

    The problem is that attribute values have to be determined at compile time - they're embedded in the assembly. That's why you have to use a constant expression (not just a global variable - truly a constant).

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