如何区分托管库是在 ASP.NET 应用程序上下文中运行还是在可执行文件中运行?

发布于 2024-08-27 01:49:18 字数 47 浏览 4 评论 0原文

如何区分托管库是在 ASP.NET 应用程序上下文中运行还是在可执行文件中运行?

how to differentiate whether a managed library is running in the context of asp.net application or in a executable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

魂归处 2024-09-03 01:49:19

这个问题其实没有多大意义。一个过程就是一个过程。但是您也许可以通过检查 HttpContext.Current 是否为 null 来判断您的库是否由 ASP.NET 加载。

This question doesn't really make a lot of sense. A process is a process. But you may be able to tell if your library is loaded by ASP.NET by checking to see if HttpContext.Current is null.

坠似风落 2024-09-03 01:49:18

您可以检查 HttpContext.Current 是否返回 null

从技术上讲,如果 ASP.NET 应用程序在非工作线程上运行(即,如果您只是使用 new Thread(SomeProc)),它也会在 ASP.NET 应用程序中返回 null,但是它应该在 99% 的时间里都能工作。

You could check whether HttpContext.Current returns null or not.

Technically, it'll also return null in an ASP.NET application if it's running on a non-worker thread (i.e. if you just go new Thread(SomeProc)) but it should work 99% of the time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文