Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Does Not Exist Exception in VS2010

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)
like image 554
Mike Avatar asked Jun 27 '10 21:06

Mike


2 Answers

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.

like image 74
Brian Gideon Avatar answered Sep 23 '22 06:09

Brian Gideon


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?

like image 33
Cylon Cat Avatar answered Sep 23 '22 06:09

Cylon Cat