Global.asax 问题

发布于 2024-07-29 16:40:29 字数 333 浏览 4 评论 0原文

我正在开发 HttpModule 并使用 Global.asax。 我开发了一个派生自 HttpApplication 的类,但我的类的 Application_Start 方法永远不会执行(我在 Application_Start 的开头创建一个文件,但该文件永远不会创建,这就是为什么我认为 Application_Start 永远不会执行)。 我使用的是 VSTS2008 + C# + .Net 3.5。

任何想法出了什么问题以及如何调试? 我想确认我应该将 Global.asax 复制到我的网站虚拟目录的根目录中,对吗? 我应该在 web.config 中配置任何内容来让 HttpModule 运行吗?

I am developing an HttpModule and using Global.asax. I have developed a class which derives from HttpApplication, but Application_Start method of my class never executes (I create a file at the beginning of Application_Start but the file never creates, and it is why I think Application_Start never executes). I am using VSTS2008 + C# + .Net 3.5.

Any ideas what is wrong and how to debug? I want to confirm I should copy the Global.asax into the root directory of my web site virtual directory, correct? Should I configure anything in web.config to let the HttpModule run?

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

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

发布评论

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

评论(3

天涯离梦残月幽梦 2024-08-05 16:40:29

Application_Start 仅在应用程序首次启动时执行一次。 您是否重新启动了您的应用程序?

是的,Global.asax 必须位于根目录中。

您必须将新的 ASP.NET 模块添加到 web.config中 部分。

Application_Start executes only once when an application starts first time. Do you have restarted your application?

Yes, Global.asax must be in the root directory.

You must add your new ASP.NET module into web.config <httpModules> section.

亣腦蒛氧 2024-08-05 16:40:29

您是否将模块添加到 web.config 中的 httpModules 部分? 请参阅:http://msdn.microsoft.com/en-us/library/ ms227673.aspx

Did you add your module to the httpModules section in your web.config? See: http://msdn.microsoft.com/en-us/library/ms227673.aspx

梦里°也失望 2024-08-05 16:40:29

您确实需要在 web.config 中添加一个条目
http://msdn.microsoft.com/en-us/library/9b9dh535。 ASPX

you do need to add an entry into web.config
http://msdn.microsoft.com/en-us/library/9b9dh535.aspx

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