Link to home
Start Free TrialLog in
Avatar of Steve Endow
Steve EndowFlag for United States of America

asked on

ASP.NET MVC Controller Error: The resource cannot be found - HTTP 404

I have an existing Visual Studio 2013 ASP.NET MVC web service app that works fine on Dev Server A.  I can launch and debug the web service and everything works properly.

I am setting up the project on a new server, Dev Server B, trying to match the configuration of Server A.  The Visual Studio code has not been changed.  I have the code working and debugging on Dev Server B, but one of the controller methods is not working for some reason.  The other controller methods work fine.

If I access the URL on Dev Server B:

http://localhost:1881/DynamicsIntegration/CheckStatus2

I get this error: The resource cannot be found HTTP 404

User generated image

Strangely, if I rename the method name in the controller to anything else, it works fine.  CheckStatus1, CheckStatusA, etc. work fine.  But "CheckStatus2" does not work.

User generated image
When this error occurs, no breakpoints are hit in the CheckStatus2 code, and no breakpoints in the controller are not hit.  When I rename the method, it works fine.

I don't think I have any routing setup, and haven't been able to find anything that may be causing "CheckStatus2" to be an invalid route.  My assumption is that something is getting cached in IIS or some routing hint is causing the problem, but I can't find any clues.

How can I troubleshoot this or track down the problem?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

have you checked the RouteConfig.cs and if you did the routes.MapRoute correctly there?
Avatar of Steve Endow

ASKER

Hi Ryan,

Thanks for the suggestion.  I am not familiar with RouteConfig.cs, but the file contents are below.  The file is the same on both Server A and Server B, and I've never edited it before.  What puzzles me is that every other method/endpoint I have tested on the same controller works--only CheckStatus2 has this issue so far.

Is there a way to debug-level ASP.NET MVC logs for an incoming request and see what is triggering the 404 error?  Presumably it's looking for a method or route that isn't valid for some reason.

I know how to troubleshoot this with ASP.NET Core, but am not familiar with how to get such detailed logging with ASP.NET MVC.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace TSM.Integration.Services
{
    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 }
            );
        }
    }
}

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.