asp.net确认对话框

Dialogs on the server-side? What is this nonsense of which you speak? Are you insane? Sadly no.

服务器端的对话框? 您说的这胡话是什么? 你疯了? 可悲的是没有。

Back in the day, if you ran a VB6 COM DLL under Classic ASP, or as I like to call it "Poopy-SP," and you forgot to set "Unattended Execution" and "Retain in Memory" you could get yourself into a pickle if an error in the application caused a dialogbox or messagebox to pop up on the Server-side, just waiting for some poor schmuck to click "OK."

回顾过去,如果您在经典ASP下运行VB6 COM DLL,或者我喜欢将其称为“ Poopy-SP”,而您却忘记设置“无人参与执行”和“保留在内存中”,则可能会陷入困境。如果应用程序中的错误导致在服务器端弹出对话框或消息框,则请选择“腌制”,只需等待一些糟糕的选项即可单击“确定”。

Recently I got an email that a high-powered blogger was seeing Dialog Boxes on his hosted instance of DasBlog while running under ASP.NET 2.0. These dialogs would hang the thread they were on, and hang IIS until they were dismissed. Shocked he and I were to say the least as "that ain't supposed to happen."

最近,我收到一封电子邮件,内容是功能强大的博客作者在ASP.NET 2.0下运行时,在其托管的DasBlog实例上看到对话框。 这些对话框将挂起它们所在的线程,并挂起IIS,直到将其关闭。 令我震惊的他和我至少要说“那不应该发生的”。

I suggested that he disable JIT Debugging in his registry. He tried it and indicated that he was getting a full stack trace inside the message box. Since the JIT Debugging Dialog doesn't look like that, I figured that wasn't the problem.

我建议他在注册表中禁用JIT调试。 他尝试了一下,并指出他正在消息框中获得完整的堆栈跟踪 由于“ JIT调试对话框”看起来并非如此,因此我认为这不是问题。

I spoke to some folks at MSFT who said that if there were unhandled exceptions being thrown from DasBlog, how they'd be presented would be controlled via the legacyUnhandledExceptionPolicy setting in his web.config like this (we don't have any unhandled exceptions, BTW, there's 'global' exception handlers in two places):

我曾与MSFT的一些人交谈,他们说,如果DasBlog抛出了未处理的异常,将如何通过它们在web.config中的legacyUnhandledExceptionPolicy设置来控制如何呈现这些异常(我们没有任何未处理的异常,顺便说一句,在两个地方有“全局”异常处理程序):

<configuration>
  <runtime>
    <legacyUnhandledExceptionPolicy enabled="true" />
  </runtime>
</configuration>

<配置> <运行时> <legacyUnhandledExceptionPolicy enabled =“ true” /> </运行时> </ configuration>

This tells the CLR to act more like .NET 1.1 in this respect as the behavior for unhandled exceptions has changed in 2.0 (MSDN Mag Article here and MSDN Topic here).

这告诉CLR在这方面的行为更像.NET 1.1,因为未处理异常的行为在2.0中有所更改(此处为MSDN Mag文章,此处为MSDN主题)。

This "solution" smelled fishy to me, didn't seem like a good idea, and ultimately didn't solve his problem.

这个“解决方案”对我来说很腥,似乎不是一个好主意,最终没有解决他的问题。

He then indicated that he was seeing errors in our SharedBasePageErrorHandler, which made sense to me as we handle all Page-level exceptions there.

然后,他指出他在我们的SharedBasePageErrorHandler中看到错误,这对我们来说很有意义,因为我们在那里处理所有页面级异常。

private void SharedBasePageErrorHandler(object sender, EventArgs e )
{
    Exception pageException = Server.GetLastError();
    try
    {
        loggingService.AddEvent(
            new EventDataItem(EventCodes.Error,
            pageException.ToString().Replace("\n","<br>"),
            this.Page.Request.Url.ToString()));
        System.Diagnostics.Trace.Fail(this.Context.Error.Message);
    }
    catch
    {
    }
}

私人void SharedBasePageErrorHandler(object sender,EventArgs e) { 异常pageException = Server.GetLastError(); 尝试{ loggingService.AddEvent( 新的EventDataItem(EventCodes.Error, pageException.ToString()。Replace(“ \ n”,“ <br>”), this.Page.Request.Url.ToString())); System.Diagnostics.Trace.Fail(this.Context.Error.Message); } 抓住{ } }

Seems pretty straightforward, and his stuff WAS getting logged indicating that the LoggingService.AddEvent was working fine.

看起来非常简单,并且他的东西被记录下来,表明LoggingService.AddEvent运行正常。

What about this System.Diagnostics.Trace.Fail call, though? Seems harmless, but it's the only other thing in there and it would explain where the stack trace was coming from - it's inside of this.Context.Error.Message.

但是,该System.Diagnostics.Trace.Fail调用又如何呢? 看起来是无害的,但这是其中唯一的另一件事,它可以解释堆栈跟踪的来源-它位于this.Context.Error.Message内部。

There was a problem back in the day with Trace.Fail or Debug.Fail locking up the ASP.NET Worker Process.

有一个问题,早在与Trace.Fail或Debug.Fail锁定了ASP.NET工作进程的一天

If you reflector into the implementation of the DefaultTraceListener in the .NET Framework you'll see a call to AssertWrapper.ShowAssert (that should only happen if AssertUIEnabled is true and UI Permissions are available.) That must be the case in our blogger friend's situation.

如果您反映了.NET Framework中DefaultTraceListener的实现,您将看到对AssertWrapper.ShowAssert的调用(仅在AssertUIEnabled为true且UI权限可用时才发生。)在我们博客作者的情况下一定是这种情况。

public override void Fail(string message, string detailMessage)
{
      string text1;
      StackTrace trace1 = new StackTrace(true);
      int num1 = 0;
      bool flag1 = DefaultTraceListener.UiPermission;
      try
      {
            text1 = this.StackTraceToString(trace1, num1, trace1.FrameCount - 1);
      }
      catch
      {
            text1 = "";
      }
      this.WriteAssert(text1, message, detailMessage);
      if (this.AssertUiEnabled && flag1)
      {
            AssertWrapper.ShowAssert(text1, trace1.GetFrame(num1), message, detailMessage);
      }
}

公共重写无效失败(字符串消息,字符串detailMessage) { 字符串text1; StackTrace trace1 =新的StackTrace(true); int num1 = 0; bool flag1 = DefaultTraceListener.UiPermission; 尝试{ text1 = this.StackTraceToString(trace1,num1,trace1.FrameCount-1); } 抓住{ text1 =“”; } this.WriteAssert(text1,message,detailMessage); 如果(this.AssertUiEnabled && flag1) { AssertWrapper.ShowAssert(text1,trace1.GetFrame(num1),message,detailMessage); } }

Assuming those things are true and ShowAssert does get called, interally the AssertWrapper.ShowAssert calls SafeNativeMethods.MessageBox only if the user is in an interactive mode. It's possible that MB_SERVICE_NOTIFICATION isn't being passed into the MessageBox indicating that it's a non-interactive service who is throwing the box.

假设这些情况是正确的,并且ShowAssert确实被调用,则只有当用户处于交互方式时,AssertWrapper.ShowAssert才会内部调用SafeNativeMethods.MessageBox。 MB_SERVICE_NOTIFICATION可能没有传递到MessageBox中,表明它是抛出该框的非交互式服务。

Setting this option in the web.config (or machine.config) works around the issue by not even getting into AssertWrapper.

在web.config(或machine.config)中设置此选项可以解决该问题,甚至不需要进入AssertWrapper。

<configuration>
   <system.diagnostics>
      <assert assertuienabled="false" logfilename="c:\log.txt"/>
   </system.diagnostics>
</configuration>

<配置> <system.diagnostics> <assert assertuienabled =“ false” logfilename =“ c:\ log.txt” /> </system.diagnostics> </ configuration>

This looks like a bug in ASP.NET 2.0, but we'll see.

这看起来像是ASP.NET 2.0中的错误,但我们会看到。

The workarounds are:

解决方法是:

  • Don't use Trace.Fail()不要使用Trace.Fail()

or

要么

  • Set AssertUIEnabled="false" in your web.config.在您的web.config中设置AssertUIEnabled =“ false”。

The strange part about this is why it's seen on some systems and not others.

奇怪的是,为什么它在某些系统而不是其他系统上可见。

翻译自: https://www.hanselman.com/blog/preventing-dialogs-on-the-serverside-in-aspnet-or-tracefail-considered-harmful

asp.net确认对话框

asp.net确认对话框_在ASP.NET或Trace.Fail中防止服务器端对话框被认为有害相关推荐

  1. 访问 asp网页 白屏_(02)ASP如何设定主目录和默认文档

    本节主要介绍更改ASP文件存储主目录,即在服务器计算机上的物理路径和设定默认访问文档两个问题.这两个问题一解决,我们就可以进行程序设计的动态网页互动环节了. 一. 更改主目录 1. 以Windows ...

  2. asp easp 开源框架_国内ASP开源建站系统一览

    开源建站程序让编程高手和只懂打字上网的人都可以快速建立一个功能强大.界面漂亮的网站.不管你是想建一个博客.论坛.CMS.电子商务网站,或是Wiki.相册管理.RSS聚合和类Digg网站.你都可以通过这 ...

  3. asp绑定gridview属性_理解ASP.NET Core中的模型验证

    当MVC执行模型绑定后,为了验证绑定为参数提供的值是否符合预期,还需要进行模型验证. 一.理解模型验证 模型验证是指模型绑定后对Action参数进行验证的过程.它会根据事先定义的规则对参数的值进行验证 ...

  4. asp mysql 留言本_适用于ASP.NET的留言本(翻译)

    目录 绪论 这是一个允许web站点上的访问者在留言本上留言的项目.项目建立了两个部分: 在留言本上留言. 浏览留言本上的内容. 数据库 这个留言本使用的是放在服务器上的一个名叫 guestbook.x ...

  5. 火狐网页对话框_默认情况下,在Firefox中展开“添加书签”对话框

    火狐网页对话框 If you are reading this article you are probably annoyed that every single time you add a bo ...

  6. MFC中的模态对话框与非模态对话框的消息循环及消息传递问题(都可以通过SendMessage传递消息)

    注意:非模态和模态对话框都有自己的消息响应过程函数WindowPro,只不过他们的调用模态是自己的消息泵,非模态是由父窗体或父窗体的上一级的消息泵来调用.模态对话框和非模态对话框都可以通过SendMe ...

  7. 在MFC工程中新建一个对话框

    1.MFC简介 Microsoft Foundation Class微软基础类库,这个类集以层次结构组织起来,其中封装了发部分的Windows API函数和Windows控件,它所包含的功能设计整个W ...

  8. asp.net应用程序_如何在ASP.NET中为聊天应用程序构建键入指示器

    asp.net应用程序 by Neo Ighodaro 由新Ighodaro 如何在ASP.NET中为聊天应用程序构建键入指示器 (How to build a typing indicator fo ...

  9. asp绑定gridview属性_如何在ASP.NET Core中自定义Azure Storage File Provider

    主题:如何在ASP.NET Core中自定义Azure Storage File Provider 作者: Lamond Lu 地址:  https://www.cnblogs.com/lwqlun/ ...

最新文章

  1. 图十字链表并求度c语言,利用十字链表存储树结构(便于同时求出某一点的入度与出度)------C语言实现...
  2. spring.net nhibernate 分布布式事务(下)
  3. 微量元素与中医药 谋定·大健康医药-李喜贵:辩证研究病理变化
  4. GoldenGate系统三:trouble shooting and log
  5. 【ArcGIS风暴】缓冲区分析、叠置分析综合实验案例:购房区域的选择
  6. 工业交换机在城市智慧轨道交通中的应用分析
  7. 23种设计模式之原型模式代码实例
  8. boltdb 学习和实践
  9. java显示毫秒改成分钟_【转】java获取当前年、月、日 、小时 、分钟、 秒、 毫秒...
  10. 【springmvc+mybatis项目实战】杰信商贸-2.数据库配置
  11. apache31分是重症吗,APACHEⅢ重症评估系统
  12. python中getattr()的用法
  13. MPEG4 笔记3(TRAK,TKHD, MVHD)
  14. 为什么你应该开始学习编程了
  15. 曲线与曲面的微分几何
  16. [ECCV2018]Generating 3D faces using Convolutional Mesh Autoencoders
  17. daimayuan每日一题#814 排队
  18. visual studio 平台工具及路径
  19. BSV 上的 Schnorr 签名
  20. c++实现猜单词游戏

热门文章

  1. 偏微分方程简明教程第七章部分答案
  2. R报warning: Removed 10 rows containing missing values (geom_point)
  3. 2022年PMI-ACP报考流程来了,快收藏
  4. 安全点、安全区域、记忆集、卡表与写屏障
  5. 线性回归-线性神经网络
  6. 电大学位计算机试题,2015年电大电大学位英语上机考试题1.doc
  7. seismic unix 绘制图像
  8. Android快速第三方分享
  9. 和几个败家朋友辛苦整理的几十家淘宝店铺,关键时候可以派上用场
  10. shell读书笔记9