File Does Not Exist Exception in VS2010
Asked Answered
F

5

9

I've taken over the code of a website from someone else to finish off and have hit the issue that every time I load a page, I get a 'File Does Not Exist' exception caught in the Application_Error handler in my Global.asax file.

I was curious what it was, so have tried creating brand new solutions with both a Web Site and Web Application, both with and without a Master Page and a single .aspx page - both had the same problem.

This is using VS2010 and .NET 3.5, on Windows 7 64-bit.

Any ideas please? The stack trace tells me absolutely nothing and the fact I'm getting it with new projects is odd.

Exception Stack Trace:

at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response)
at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context)
at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Furculum answered 27/6, 2010 at 21:14 Comment(1)
my first guess...webdesign.about.com/od/favicon/f/blfaqfavicon4.htmAisne
F
1

I never got to the bottom of this sadly and an overdue rebuild of my computer sorted it.

Furculum answered 27/2, 2011 at 10:43 Comment(0)
A
10

The trick in figuring out which file does not exist is to use the following code in the Application_Error method.

protected void Application_Error(Object sender, EventArgs e)
{
  Exception ex = Server.GetLastError().GetBaseException();
  string file = HttpContext.Current.Request.Url.ToString();
  string page = HttpContext.Current.Request.UrlReferrer.ToString(); 
}

This will retrieve the name of the file that is missing and the original page from which the request came.

Artamas answered 5/12, 2011 at 20:51 Comment(2)
I've been getting this error once a day on the first running of the app in debug mode, and using this answer I found out it was a request for favicon.ico, even though I've added favicon to the IgnoreRoutes. Any ideas on how to get rid of it altogether, other than adding a favicon.ico to the solution?Belenbelesprit
@Webbie4: No, sorry. I have no idea.Artamas
I
3

What is the file name in the exception? If the file name or the path is obfuscated, then you likely have a corruption in ASP.NET temporary files. Try "clean solution" and "rebuild solution" and run it again.

Otherwise, you'll need to post more information, including the full exception message, not just the call stack. Is this happening on the default page of the site? Is the web project selected as the startup project? Is this happening in the Visual Studio web server, or IIS?

Introduce answered 27/6, 2010 at 21:36 Comment(5)
The issue is there is no file name or extra info in the exception. I've posted everything I've got sorry. It tells me nothing useful. If I put halt on all exceptions on too, I get nothing - it still just hits the exception handler in the Global.asax file and nowhere else. I've also closed Visual Studio and create two brand new test solutions, as mentioned, so clean / rebuild won't help.Furculum
OK, that qualifies as pretty weird. The call stack tells me that you're in the ASP.NET pipeline, and it's setting up to load and process a page, but (probably) not having a page to load. It may be that the site doesn't know what the default page is, so perhaps you can try selecting a page and making it the default startup page. Or with the page open in Visual Studio, simply right-click on the page in the edit window and select View in Browser; this would tell you if there's a problem with the page.Introduce
Tried that thanks. It happens with any page, only when using Visual Studio. Once I deploy to my web server (Windows Server 2003 R2) it's fine and no errors. Within studio, there is a default page set, so won't be that. Odd - sounds like an issue with VS2010 - didn't do this with VS2008.Furculum
Very odd. I just tried a variety of new web applications (default content, empty) and web project (default content). In the empty project, I tried no pages at all, one page not named default, one page named default. All worked fine, so I'm not encountering the problem at all. One last thing to check: open the solution properties and project properties, and check to see that everything looks right. In particular, check the project properties, web tab, startup page options. If all else fails, try a clean install of VS2010 on another machine. Other than that, I'm out of ideas.Introduce
Thanks for suggestions - it is very odd yes. Will try what you say - other than that, I'm tempted to blitz the computer and start from scratch - it's been about 9 months since last rebuild anyhow! Must remember to take an image after installation this time!Furculum
K
2

I detect my error in Application_Error within gloal.asax I also get Request.Url.ToString(), this would give you the culprit resource. For example in my app I found that the Application_Error even complains about the favicon.ico, and also if you have some files missing that you might be referencing from your css, it would get caught by the Application_Error event.

actually, check out this blog for example, talks about the same issue and using the Request.Url to discover what the resource in question is. This should help http://dotbert.loedeman.nl/httpexception-file-does-not-exist

Krill answered 20/5, 2011 at 8:58 Comment(0)
F
1

I never got to the bottom of this sadly and an overdue rebuild of my computer sorted it.

Furculum answered 27/2, 2011 at 10:43 Comment(0)
M
1

I solved this for my situation ... turned out that the project properties had reverted back to "Use Current Page" (in VS 2010 - Project Properties | Start Options | Start Action).

The odd thing is that I had set the Start Options to "Specific Page:" -- so somewhere along the line VS 2010 lost track of it and defaulted back to "Use Current Page".

Rob.

Minneapolis answered 13/4, 2012 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.