John Livermore
John Livermore

Reputation: 31313

ASP.NET MVC 4 site returns 404 for image

I think this might be a routing issue, but I am not sure how to fix.

I have an image at...

<img src="/blog/images/scheduleAutoCalculation1.png">

and have verified it exists in that path. It should pull up. However, it returns a 404.

If I copy the image and load it with

<img src="/Resources/scheduleAutoCalculation1.png">

it pulls up fine. Here is my route table...

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

Any ideas on why I am getting a 404 for the first link?

Also, I don't have a BlogController class, so it is not trying to route to that (maybe it is??). The site is simple with only two controllers HomeController and StyleController.

Upvotes: 1

Views: 3274

Answers (1)

John Livermore
John Livermore

Reputation: 31313

I was trying to load images from another Views type of folder I had created. The web.config located in that directory was blocking the request. I moved the images to another folder and it works fine.

Upvotes: 1

Related Questions