How to solve exception “File does not exist”?

前端 未结 6 1655
攒了一身酷
攒了一身酷 2020-12-08 22:03

I have a basic ASP.NET MVC2 site which logs a single \"File does not exist\" error every time a view (not partial views) is loaded. I am pretty sure this is because I am ref

6条回答
  •  旧时难觅i
    2020-12-08 22:27

    Check your CSS files for url( resource_path ) where "resource_path" doesn't exist.

    I was getting the same exception. Found problem was in CSS file where an image file was missing from the project and not on the file system. For example a line like:

    background-image: url( /images/foo.png );
    

    Where "foo.png" file isn't in in the images folder.

    You can cast the last exception as an HttpException to get the HTML status code:

    HttpException httpEx = Server.GetLastError() as HttpException;
    if( httpEx != null )
        httpEx.GetHttpCode();         // Will be HTML status code, 404 in this case. 
    

    But it doesn't contain any information what file is missing. I found the missing file by checking every CSS class declaration on the page were this error was occurring.

提交回复
热议问题