如何在同一解决方案中访问另一个项目中的HttpRuntime.Cache [英] How to access HttpRuntime.Cache in another project in the same solution

查看:69
本文介绍了如何在同一解决方案中访问另一个项目中的HttpRuntime.Cache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个解决方案[LDM]中有两个项目[主项目,数据访问项目]。



主项目包含页面,脚本,图像等



数据访问项目仅包含数据库操作。



我需要访问数据访问中的HttpRuntime.Cache项目。



我该怎么做?

I have two projects [Main Project, Data Access Project] in one solution [LDM].

Main Project Contains Pages, scripts, images, etc.

Data Access Project Contains only Data Base operations.

I need to access HttpRuntime.Cache in Data Access Project.

How can i do that??

推荐答案

完全符合条件,
System.Web.HttpRuntime.Cache

但是,强烈建议您从Web应用程序传递所需的值。如果从数据访问层访问它,则无法在IIS托管的系统之外重用数据访问层。传递值最好。

However, I would strongly suggest you pass in the values you need from the web app. If you access it from your data access layer then your data access layer cannot be reused outside of a system hosted by IIS. It's better to pass the values in.


你没有。原因很简单,你自己说。 DataAccess项目完全负责访问数据库。 Http.Cache是​​UI的一部分,因此,DataAccess项目根本不应该具有对Cache的任何访问权限,也不应该关心。



为什么?好吧,首先,如果您想在WPF应用程序或WinForms应用程序或Windows应用商店应用程序中使用DataAccess项目,您已将DataAccess项目绑定到可访问这些类型中不存在的HTTP.Cache项目,因此您无法在其他类型的应用程序中重用DataAccess代码。
You don't. The reason is quite simple and you said it yourself. The DataAccess project is responsible SOLELY for access to the database. The Http.Cache is part of the UI and, hence, the DataAccess project shouldn't have ANY access to the Cache at all, nor should it care.

Why? Well, for starters, if you wanted to use the DataAccess project in a WPF app or a WinForms app or a Windows Store app, you've tied your DataAccess project to having access to a HTTP.Cache that doesn't exist in those types of projects so you can't reuse your DataAccess code in other kinds of applications.


这篇关于如何在同一解决方案中访问另一个项目中的HttpRuntime.Cache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆