检查应用程序是否基于Web [英] Check the Application is Web Based

查看:110
本文介绍了检查应用程序是否基于Web的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我开发了一个c#类库。并将其转换为dll,并将其附加到一个Web应用程序和一个Windows窗体应用程序。一些功能应该仅适用于Web应用程序。所以我想检查dll当前是否正在使用基于Web的应用程序或者不是。我可以检查一下?

Hi,
i have developed one c# class library. and i convert it as dll and attach it with one web application and one windows forms application.Some functionality should work only in web application.so i want to check the dll is currently working with web based application or not.how can i check that?

推荐答案

你没有检查它。无论呼叫者是什么类型,功能都应该是一致的。你的DLL不应该在任何与应用程序的UI有关的事情上做任何事情。它应该只处理数据。
You don't check for it. The functionality should be consistent no matter what type the caller is. Your DLL should NOT be doing ANYTHING AT ALL that has anything to do with the UI of an application. It should be handling data ONLY.


你可以尝试将信息存储在Web.config文件中,然后尝试从中读取。如果失败,你知道它必须在Winforms / WPF上。如果成功,那么您知道它必须从Web应用程序运行。这可以像布尔标志一样简单。
you could try and store the information off the Web.config file, then attempt to read from it. If it fails, you know it has to be on Winforms/WPF. If it succeeds, then you know it has to be running from a web application. This can be as simple as a boolean flag.


这篇关于检查应用程序是否基于Web的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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