简体   繁体   English

在DataAccesslayer中访问应用程序变量(同一解决方案下的另一个项目)

[英]Accessing application variables in DataAccesslayer (another project under same solution)

我有一个3个项目的解决方案。一个UI(包含网页),一个用于BL,一个用于DataAccess层。现在我想访问存储在DataAccess层项目中一个类中的应用程序变量中的一个值。应用程序变量在那里?

I recommend passing the value through your different layers. 我建议您通过不同的层传递值。

You could probably use HttpContext.Current... to access it directly, but doing it that way would mean you now have a dependancy on Session state in your DAL, which will make testing and maintainance more awkward. 您可能可以使用HttpContext.Current ...直接访问它,但是这样做将意味着您现在对DAL中的Session状态有依赖性,这将使测试和维护更加尴尬。

您需要将当前的HTTPContext传递给DAL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM