Reputation: 8942
I just started getting the “File does not exist” exception. The exception occurs after I press the Run button in visual studio. Also as far as I can tell, none of my code is hit. The code part that should hit is
public ActionResult Index() {
return View("Index");
}
But the breakpoint in that code is never hit. .. I followed How to solve exception "File does not exist"? and System.Web.HttpException File does not exist - Page loads just fine (ASP.NET) and wrote the following code:
void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex.Message == "File does not exist.")
{
var foo = Request.RawUrl;
var newEx = new Exception(string.Format("{0} {1}", ex.Message, HttpContext.Current.Request.Url.ToString()), ex);
}
}
Now when I run and hit this code, foo is set to "/" and newEX is "File does not exist. http://localhost:63456/"
Any ideas?
Here is the stack trace:
PishiWebSite.dll!PishiWebSite.MvcApplication.Application_Error(object sender, System.EventArgs e) Line 164 C# System.Web.dll!System.Web.HttpApplication.RaiseOnError() + 0xc6 bytes
System.Web.dll!System.Web.HttpApplication.RecordError(System.Exception error) + 0x40 bytes
System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) + 0x101 bytes
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0xf8 bytes
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr) + 0x284 bytes System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x6e bytes
System.Web.dll!System.Web.HttpRuntime.ProcessRequest(System.Web.HttpWorkerRequest wr) + 0x47 bytes
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Request.Process() + 0x188 bytes WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Microsoft.VisualStudio.WebHost.Connection conn) + 0x66 bytes
[Appdomain Transition]
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(object acceptedSocket) + 0xa1 bytes
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3e bytes mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 bytes mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x149 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 bytes [Native to Managed Transition]
Also typing Server.GetLastError().StackTrace.ToString()
in the Imediate Window gives:
at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) 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)
Upvotes: 2
Views: 2362
Reputation: 8942
So what had happened was this: I had the following Controller method:
public ActionResult SearchTitle(string path)
{
//lots of code here
return Index();
}
and the following route:
routes.MapRoute("SearchTitle", "{*path}",
new { controller = "Home", action = "SearchTitle", path = UrlParameter.Optional });
Since I was not using SearchTitle, I quickly deleted the method and the associated routing. This was the cause of the error.
The solution was to keep the Controller deleted, but change the routing to
routes.MapRoute("Default", "{*path}",
new { controller = "Home", action = "Index", path = UrlParameter.Optional });
Note: There was never any files missing
Upvotes: 1
Reputation: 4101
There are instances where visual studio will not hit a valid break point. Include system.diagnostics namespace and use debugger.break() to force a breakpoint. Remove from your code when your problem has been identified.
https://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.aspx
Upvotes: 2