触发多个 Application_Start 事件
我正在调试一个 ASP.NET 2.0 应用程序,该应用程序的初始页面加载缓慢。
通过添加日志记录,我发现 Application_Start
事件在启动时触发两次,两次事件之间有短暂的延迟。 Session_Start
事件也会触发两次,并具有相同的会话 ID 值。
例如
[Header] 2010-09-10 14:52:36.331 INFO Web.Global.Application_Start START 2010-09-10 14:52:37.409 INFO Web.Global.Session_Start Session.SessionID=xxqjvun2ce2yqsumq1hfoj45 [Header] 2010-09-10 14:53:10.028 INFO Web.Global.Application_Start START 2010-09-10 14:53:10.325 INFO Web.Global.Session_Start Session.SessionID=xxqjvun2ce2yqsumq1hfoj45
,我在本地计算机上的 IIS 5.1 下运行它。该项目还使用 ASP.NET MVC,并且使用的 aspx 页面 URL 通过路由进行更改,使用 Phil Haack 网站上显示的技术。
关于可能导致这种情况的任何建议?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我们最终意识到这取决于我们的 IIS 配置。
不久前,我们决定重命名该网站使用的虚拟目录。这是通过添加全新的虚拟目录配置并保留前一个虚拟目录配置来完成的。本质上,我们有两个虚拟目录指向同一个 ASP.NET 应用程序!
向新虚拟目录的迁移从未完成,因此网站的部分内容仍然引用旧虚拟目录。因此有两个
Application_Start
事件...修复方法是将 IIS 中的旧虚拟目录设置为 重定向到 URL,并将 URL 设置为 /NewVirtualDirectory$S$Q
We eventually realised that this was down to our IIS configuration.
Some time ago a decision was made to rename the virtual directory used for this website. This was done by adding a whole new virtual directory configuration, leaving the previous one in place. Essentially we had two virtual directories pointing at the same ASP.NET app!
The migration to the new virtual directory was never completed, so parts of the website still referenced the old one. Hence two
Application_Start
events...The fix was to change to setup to the old virtual directory in IIS to be A redirection to a URL with the URL set to /NewVirtualDirectory$S$Q
经过4天的努力,我终于找到问题所在了!
如果您更改 Bin 目录中的任何文件,IIS 会重置您的应用程序和应用程序池。
对我来说,这是因为我的程序曾经在 Bin 目录中写入 log.txt 文件。
我更改了日志文件路径,问题就消失了!
After spending 4 days, I have finally found the problem out!
If you change any file in Bin directory, IIS resets your application and Application pool.
For me, it was because of log.txt file that my program used to write in Bin directory.
I changed the log file path and the problem has been vanished!
我们遇到了类似的情况,只是发现这是因为我们进行了程序集重命名,并且有引用该程序集存在的相同代码的两个副本,即 versionA.dll 和 versionB.dll。因此它被调用了两次!
We had a similar situation happen only to discover that it was because we had done an assembly rename and had two copies of the same code referencing that assembly existed, versionA.dll and versionB.dll. So it was being called twice because of that!
根据我的经验(经过数小时的研究和大量的编码)
我通过文件管理从托管面板而不是 FTP (FileZilla) 中删除,并且多个
Application_Start
事件触发消失了:-) 问题的根本原因是不可阻挡的 Quartz.Net 进程已连接到此 dll。In my experienced (after hours research and tons of coding) that comes from
I deleted by File Management from hosting panel instead of FTP (FileZilla) and Multiple
Application_Start
events firing gone :-) Root causes of problems was unstoppable Quartz.Net process that was connected to this dll.