神秘“文件不存在” global.asax 中的错误(与任何类型的文件 IO 无关的代码)
我收到“文件不存在”错误。在我的 ASP.NET 应用程序中。不过,这很奇怪。
首先,周围没有文件 IO 代码 - 当它发生时我不会对任何文件执行任何操作。
另外,它发生在 global.asax 中 Application_Error() 方法的最后一个右大括号上(这是您放入代码来处理未处理的异常的方法)。没错:它不会出现在 throw 语句或任何有意义的代码行上,而是出现在最后一个花括号上。
目标站点是:
{系统.IO.文件信息 获取文件信息(系统.String, 系统.字符串, System.Web.HttpResponse)}
在我看来,这就像 ASP.NET 内部的东西(我的解决方案中没有 GetFileInfo() 方法)。
StackTrace 只是:
在 ASP.global_asax.Application_Error(对象发送者,EventArgs e)中 c:\Subversion\ConfApp\Website\Global.asax:第 36 行 System.EventHandler.Invoke(对象 发送者、EventArgs e) at System.Web.HttpApplication.RaiseOnError()
我无法从中得出任何线索。
其他详细信息:
我正在尝试解决此应用程序中 jQuery 1.4(和 jquery UI)和 MS ASP.NET AJAX 4 之间的冲突
它是在我将应用程序从 .net 2.0 升级到 .net 4 和 Visual Studio 2010 后开始的。
知道我如何开始研究这个问题吗?
更新:
发布此文后不久,我删除并重新添加了 jquery UI(包括 .js、.css 和图像)。到目前为止,看起来这个问题已经解决了。不确定客户端 JS 库如何导致 Global.asax 中出现错误。不过,如果错误不会很快再次出现,则会将其添加为答案...
I'm getting a 'File does not exist' error. In my ASP.NET app. This is a strange one, though.
Firstly, there is no file IO code anywhere around - I'm not doing anything with any files when it occurs.
Also, it's happening on the very last closing curly brace of the Application_Error() method in global.asax (that's the one you put code in to handle unhandled exceptions). That's right: it doesn't occur on a throw statement, or any line of meaningful code, but right on the last curly brace.
The TargetSite is:
{System.IO.FileInfo
GetFileInfo(System.String,
System.String,
System.Web.HttpResponse)}
Which looks to me like something internal to ASP.NET (there is no GetFileInfo() method in my solution).
The StackTrace is only:
at
ASP.global_asax.Application_Error(Object sender, EventArgs e) in
c:\Subversion\ConfApp\Website\Global.asax:line 36 at
System.EventHandler.Invoke(Object
sender, EventArgs e) at
System.Web.HttpApplication.RaiseOnError()
From which I can derive no clues.
Other details:
I'm in the middle of trying to resolve conflicts between jQuery 1.4 (and jquery UI) and MS ASP.NET AJAX 4 in this app at the moment
It started after I upgraded the app from .net 2.0 to .net 4 and visual studio 2010.
Any idea how I might start looking into this?
Update:
Shortly after posting this, I removed and re-added jquery UI (including .js, .css and the images). So far, it looks like this has fixed it. Not sure how a client-side JS library might cause an error in Global.asax. Will add this as the answer, though, if error doesn't show up again soon...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 ApplicationError 方法中,检查 Request.CurrentExecutionFilePath。 CurrentExecutionFilePath 应指示请求哪个文件。
检查此属性帮助我确定 Chrome 自动请求“/favicon.ico”。如果没有图标,即使页面加载得很好,您也会收到“文件不存在”的消息。顺便说一句,IE 和 FF 不会这样做。
Within the ApplicationError method, check Request.CurrentExecutionFilePath. CurrentExecutionFilePath should indicate which file was requested.
Checking this property helped me determine that Chrome automatically requests "/favicon.ico." If there is no favicon, you'll get a "File does not exist," even thought the page loads just fine. BTW, IE and FF do not behave this way.
一天后,问题似乎消失了。
我删除并重新添加了 jquery UI(包括 .js、.css 和图像)。到目前为止,看起来这个问题已经解决了。很奇怪。
A day later, and the problem appears to be gone.
I removed and re-added jquery UI (including .js, .css and the images). So far, it looks like this has fixed it. Very strange.
使用 Perry 在
Application_Error
中检查Request.CurrentExecutionFilePath
的建议,我发现我的 ASP.Net 应用程序无法在前缀为"~/ 的文件夹中找到 jQuery 文件
。标记中的“
我在我的 MasterPage 标记中这样做:
当我应该这样做时:
Using Perry's suggestion of examining
Request.CurrentExecutionFilePath
inApplication_Error
, I found that my ASP.Net app couldn't find the jQuery files in folders prefixed with"~/"
in the<script>
tag.I was doing this in my MasterPage markup:
when I should have been doing this: