运行时 HttpException 仅影响一页/用户控件

发布于 2024-09-02 16:19:08 字数 474 浏览 1 评论 0原文

我们在 .NET 3.5 WebForms 站点上遇到问题,错误日志中偶尔会出现以下错误消息:

“找到具有相同 ID 'ctl09' 的多个控件。FindControl 要求控件具有唯一 ID。”

我对该异常知之甚少,因为我在本地调试时从未见过它,也从未在错误日志中及时捕获它来运行远程调试会话。我确实知道应用程序池回收可以解决该问题。

这仅影响网站中的单个[高流量]页面。奇怪的是,该网站使用了 4.0 之前的 ID 生成逻辑。因此,当页面工作时,整个视图源中没有一个 html 元素不是一些自动生成的控件 ID 前缀后跟“实际”ID(即 ctl09_someID_someOtherID)。

所以,有两个主要问题,尽管任何想法都是受欢迎的:

  1. 什么情况下控件会随机停止正确构建?
  2. 除了 Global.asax 之外,我如何捕获此错误并强制控件...重新编译?应用程序池要回收吗?

我很困惑。

We're having an issue with a .NET 3.5 WebForms site where occasionally our error logs start filling up with the following error message:

"Multiple controls with the same ID 'ctl09' were found. FindControl requires that controls have unique IDs."

I know very little about the exception as I have never seen it while debugging locally and have never caught it in the error logs soon enough to run a remote debugging session. I do know that an application pool recycle fixes the issue.

This only affects a single [high traffic] page in the site. The strange thing is that the site uses the pre-4.0 ID generation logic. So, when the page is working, there isn't an html element in the entire view source that isn't some autogenerated control ID prefix followed by a the 'actual' IDs (i.e. ctl09_someID_someOtherID).

So, 2 primary questions, though any ideas are welcome:

  1. What would case a control to randomly stop being built correctly?
  2. Other than the Global.asax, how can I trap this error and force the control to ... recompile? App pool to recycle?

I'm pretty much stumped.

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

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

发布评论

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

评论(1

神也荒唐 2024-09-09 16:19:08
  1. 据我所知,只有干扰页面生命周期或 AJAX 回发的外部实体可能会导致这种情况,如果依次生成每个控件,那么您将不会“随机”遇到重复的 id。 据我所知,没有

  2. 我认为这不是一个可行的选择,应用程序池回收?不可能,这必须有一个正当的理由。

也许更多的信息/代码会有用?这是一个特定的页面吗?您使用 ViewState 吗?控制 ID 出现“狡猾”的原因有很多。

  1. Nothing as far as I'm aware, only an outside entity interferring with the page lifecycle or AJAX postback could potentially cause this, if each control is being generated, in turn, then you will not 'randomly' experience duplicate ids.

  2. I don't think this is a viable option, app pool recycle? No way, there's got to be a valid reason for this.

Perhaps some more info/code would be useful? Is it a particular page? Are you using ViewState? There's lots of reasons for 'dodgy' control ids.

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