ASP.net MVC HttpException奇怪找不到文件 [英] ASP.net MVC HttpException strange file not found

查看:315
本文介绍了ASP.net MVC HttpException奇怪找不到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS6运行asp.net MVC的网站 - 我已经编辑我的路由如下所示:

I'm running asp.net MVC site on IIS6 - I've edited my routing to look like the following:

  routes.MapRoute(
            "Default",                              
            "{controller}.aspx/{action}/{id}",   
            new { controller = "Home", action = "Index", id = "" }  
        );

        routes.MapRoute(
         "Root",
         "",
         new { controller = "Home", action = "Index", id = "" }
       );

所以,我的所有URL现在包含的.aspx(按从菲尔哈克的解决方案之一)。现在,我赶上使用ELMAH所有未处理的异常,并且几乎每一个页面请求,我得到ELMAH抓住了以下错误,我从来没有看到在前端(一切完美):

So all my urls now contain .aspx (as per one of the solutions from Phil Haack). Now, I catch all unhandled exceptions using Elmah, and for almost every page request, I get the following error caught by Elmah, that I never see on the front end (everything works perfectly):

System.Web.HttpException: The file '/VirtualDirectoryName/Home.aspx' does not exist.

System.Web.HttpException: The file '/VirtualDirectoryName/Home.aspx' does not exist.
   at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

有一个Home控制器,它应该可以找到,但我不知道a)此举是从所谓的,和b)为什么我没有看到在前端此错误。任何想法?

There is a Home controller, and it should be found, but I'm not sure a) where this is being called from, and b) why I don't see this error on the front end. Any ideas?

推荐答案

我可能是错我的初步答案。我认为问题在于,我没有为我的网站图标,而这个请求(每个浏览器刷新)正在由MVC运行时处理。

I may have been wrong with my initial answer to this. I think the problem lies in the fact that I did not have a favicon for my site, and that this request (on each browser refresh) was being processed by the MVC runtime.

添加一个图标和忽略路径(如以下链接的问题,似乎正确排序了这一点。

Adding a favicon and an ignore route (as in the question linked below, seems to sort this out properly.

在ASP.NET MVC服务favicon.ico的

我要离开这个环节上为好,因为是我经过这里工作过的一些有用的物品:

I'm leaving this link on as well, as there was some useful items that I worked through here too:

ASP.NET MVC IIS6上

这篇关于ASP.net MVC HttpException奇怪找不到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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