如何阻止Application_Start被多次调用? [英] How do I stop Application_Start from being called multiple times?

查看:224
本文介绍了如何阻止Application_Start被多次调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我们开发的网页有疑问。



这是一个单页的网站,用户可以通过电子邮件获得链接。该网站会生成我们希望他们出价的所有订单项,每个订单项都在一个单独的行中。



然后,用户可以输入品牌/型号,每件商品的价格以及每件商品的任何评论。



我们最近收到了很多错误,看起来像是:

1)对象引用没有设置为一个实例对象。

抛出类型'System.Web.HttpUnhandledException'的异常(通过电子邮件消息给程序员)。



2)保存报价时出错(在网站错误页面上)。



我们最近为出价用户添加了将附件添加到出价中的功能。然后,我们会使用其出价信息保存其附件。由于添加了这篇文章,我们遇到了更高级别的错误消息(主要是错误#1)。



当我们一直在查看代码时,我们注意到的最大问题(到目前为止)是Application_Start事件处理程序似乎被多次调用。这导致清除会话变量和对象引用错误。我们看到的最大问题是它似乎是随机的。它可以成功运行任意次,但突然间我们会在短时间内遇到一系列错误,然后很长一段时间再没有任何错误。



是否有其他人遇到过他们的代码触发了Application_Start事件处理程序的多个内容的情况?我的理解是它应该只在Web服务器第一次启动应用程序时触发。之后,除非关闭应用程序,否则不应再次触发/触发事件。



关心

I have a problem with a web page that we've developed.

It is a one-page website that users are provided a link to (via an email). The site produces all the line items we want them to bid on, each on a separate line.

The users can then enter the make/model, and price per item, and any comments about each item.

We've been receiving a lot of errors recently that either look like:
1) Object reference not set to an instance of an object.
Exception of type 'System.Web.HttpUnhandledException' was thrown (via email message to programmers).
OR
2) Error saving Quote (on the website error page).

We recently added the ability for users that make bids, to add their attachments to their bid. We then save their attachments with their bid information. Since this piece has been added, we've been experiencing much higher levels of error messages (mainly error #1).

When we've been tracing through the code the biggest problem we've noticed (thus far) is the Application_Start event handler seems to be getting called multiple times. This leads to the clearing out of our session variables and Object Reference errors. The biggest problem we are seeing, is that it seems random. It can run any number of times successfully, but suddenly we end up with a slew of errors in a short while, then later, nothing again for a long time.

Has anyone else run into a situation where their code has been triggering multiple intstances of the Application_Start event handler? My understanding is that it should only fire the first time a web-server starts the application. After that, unless the application is shut down, the event shouldn't be triggered/fired again.

Regards

推荐答案

这篇关于如何阻止Application_Start被多次调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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