捕获异常在ASP.NET从通用处理程序(ASHX)文件产生 [英] Catch exceptions in ASP.NET resulting from Generic Handler (ashx) file

查看:1432
本文介绍了捕获异常在ASP.NET从通用处理程序(ASHX)文件产生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个不同的服务器端的堆栈与我的ASP.NET网站的运作。我的ASHX文件似乎被抛500内部服务器错误。我如何找出异常此ashx的文件被抛出或500的原因被抛出?当我附上我的IIS 7 W3wp.exe进程,它不会抛出异常,但我看,这是有可能的情况下。



该文件的ashx 。住在我的ASP.NET站点的根目录,属性有它设置编译

  GET HTTP:// UHC-8:8883 / MyApp的/ ExtDirectProxy.ashx 500(内部服务器错误)的index.html:27 
未捕获类型错误:不能为空EXT-ALL-debug.js的读取属性isProvider:74832
允许右键点击初始化对于http:// UHC-8:8883 / MyApp的/ index.html的rightclick.js:1
允许右击处理的http:// UHC-8:8883 / MyApp的/ index.html中单击鼠标右键。 JS:25


解决方案

如果你有一个名为App_Code文件文件夹,你可以通过头痛
和migranes。或者干脆像
代码或数据一些随机名称取代App_Code文件,并把你的类在那里解决这个问题。在我的
的情况下,我的项目GUID是一个Web应用程序和C#键入




最佳答案:



App_Code文件夹问题



注意:



我正在使用IIS的网站静态端口,而不是使用Visual Studio 2012年动态端口。我有在网络服务器上的特定服务器的配置,所以我希望网站的行为同样的方式我们发布网站的作品。所以这就是为什么我运行它像



回答我的问题:



这发生,因为我们必须在bin文件夹App_Data文件类重复的版本。 编译版本*的.cs,而*的.cs的网站版本。当多个类存在同名发生在isProvider错误。当我们部署ASP.NET应用程序中,我们只部署*的.cs文件的编译版本。发展环境,我们让他们设置属性>生成操作>无。



不知道的围绕一个简单的方法。它可能有临时和/或文件夹OBJ有事情要做,但不能完全确定。将采取多一点的故障排除发现为什么。与此同时,这里是来解决问题的事情的清单。 。不知道某些或所有这些都是必要的,但它的工作现在



步骤来解决:




  • 所有程序App_Data *的.cs文件更改属性>生成操作>编译

  • 修正他们扔来获取构建工作了例外 - 清理解决方案>生成解决方案...的唯一例外的是不能与那些设置属性抓到>生成操作>无,所以这就是为什么这是必要的。从本质上讲,视觉Studio 2012中不抛出异常并说:建立成功的。

  • 然后更改的App_Data *的.cs文件传回属性>生成操作>无
  • 删除DLL的出\obj\Debug的

  • 删除DLL的出\bin

  • <李>删除临时ASP .NET文件 - C:\WINDOWS\Microsoft.NET\Framework\ {.NET版本} \Temporary ASP.NET Files\
  • 生成解决方案

  • 重新启动IIS网站



现在,事情工作的伟大



编辑:



实际问题是,我引用在Visual Studio的外部项目,但有没有它的dll文件,因为该项目类型是控制台应用程序,而不是类库。真正的问题是,Visual Studio中说,它编译代码罚款(App_Code文件)当你有一个使用语句,其他项目,但是他说成功搭建,即使生成操作>编译选项设置为所有*的.cs文件App_Code文件。当您运行Web应用程序,它必须重新设置为生成操作>无为它工作。然而,由于*的.cs的App_Code文件的文件实际上并没有新的代码编译(如果这是ASP.NET在IIS中如何处理这些App_Code文件*的.cs文件),它抛出500内部服务器错误,因为没有很好的CIL代码在运行时。为了解决这个问题,我只是改变了项目类型为类库,它仍然没有错误,但是现在它可以基准的DLL到其他项目。



isProvider错误总是当有发现重复出现的类。所以我不知道为什么发生这种情况,但基本上消失,一旦你解决以上的部分。


I am trying to get a different server side stack functioning with my ASP.NET site. My ashx file seems to be throwing a 500 Internal Server Error. How do I figure out what exception this ashx file is throwing or the reason the 500 is being thrown? When I attach to my IIS 7 w3wp.exe process, it doesn't throw an exception, but I'm reading that this is likely the case.

The ashx file lives in the root directory of my ASP.NET site, and the Properties have it set to compile.

GET http://uhc-8:8883/MyApp/ExtDirectProxy.ashx 500 (Internal Server Error) index.html:27
Uncaught TypeError: Cannot read property 'isProvider' of null ext-all-debug.js:74832
allow right click initializing for http://uhc-8:8883/MyApp/index.html rightclick.js:1
allow right click processing http://uhc-8:8883/MyApp/index.html rightclick.js:25

解决方案

If you have a folder called "App_Code", you can go through headaches and migranes. Or simply replace "App_Code" with some random name like "code" or "data" and put your classes in there to fix this. In my case, my project GUID was a Web Application and C# type.

Best Answer:

App_Code folder issues

Note:

I am running the site using IIS with a static port, not using Visual Studio 2012 with a dynamic port. I have specific server configuration on the web server, so I want the site to behave the same way our released site works. So that's why I run it like that.

Answer to my question:

This occurred because we had duplicate versions of the App_Data classes in the bin folder. The "Compile" version of the *.cs, and the website version of the *.cs. The "isProvider" error happens when more than one class with the same name exists. When we deploy the ASP.NET application, we deploy ONLY the compiled version of the *.cs files. The development environment, we keep them set to Properties > Build Action > None.

Not sure of an easy way around that. It might have to do with having things in the temporary and/or obj folder, but not sure exactly. Will take a little more troubleshooting to discover why. In the mean time, here is a list of things to resolve the issue. Not sure if some or all of these were necessary, but it's working now.

Steps to fix:

  • change all App_Data *.cs files to Properties > Build Action > Compile
  • Fix exceptions they throw to get that build working again - Clean Solution > Build Solution ... one exception was not caught with those set to Properties > Build Action > None, so that's why this was necessary. Essentially, Visual Studio 2012 does not throw an exception and says "Build Successful".
  • then change App_Data *.cs files back to Properties > Build Action > None
  • remove dlls out of \obj\Debug
  • remove dlls out of \bin
  • remove temporary ASP.NET files - C:\WINDOWS\Microsoft.NET\Framework\{.NET version}\Temporary ASP.NET Files\
  • Build Solution
  • restart IIS web site

Now things work great!

EDIT:

Actual problem was that I was referencing an external project in Visual Studio, but there was no dll file for it because the project type was Console Application, not Class Library. The real problem was that Visual Studio says it compiles the code fine (in App_Code) when you have a using statement to that other project, but says Built Successfully, even when the Build Action > Compile option is set for all *.cs files in App_Code. When you run the web application, it has to be set back to Build Action > None for it to work. However, since the *.cs files in App_Code didn't actually compile with the new code (if that's how ASP.NET in IIS treats these App_Code *.cs files), it throws the 500 Internal Server error because there's no good CIL code during runtime. To solve it, I just changed the project type to Class Library, and it still has no errors, but now it can reference the dll to the other project.

The isProvider error always occurs when there are duplicate classes found. So I'm not sure why that occurs, but that essentially goes away once you fix the part above.

这篇关于捕获异常在ASP.NET从通用处理程序(ASHX)文件产生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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