dizar47 dizar47 - 14 days ago 9
ASP.NET (C#) Question

Error page in ASP MVC

My 404.html contains:

<img class="img-responsive center-block" src="Images/error404.png"/>


My Web.config in the project folder contains:

<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404"/>
<error statusCode="404" path="404.html" responseMode="File"/>
</httpErrors>


I can access image through
http://localhost:53870/Images/error404.png
in browser.

Image in 404.html is loading when i call it directly

localhost:53870/404.html


Or when i call

http://localhost:53870/NonexistentController


Image in 404.html ISN'T loading when i call something like this

http://localhost:53870/Home/NonexistentAction


enter image description here

Answer

You are missing a backslash at the start of the image path.

Change:

<img class="img-responsive center-block" src="Images/error404.png"/>

To:

<img class="img-responsive center-block" src="/Images/error404.png"/>
Comments