resource cannot be found issue

rob m 261 Reputation points
2021-08-23T04:15:26.3+00:00

I have an entity framework app I am rehabilitating.
all the routes work just the one labeled details fails with the error below.

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Survey/Details/3

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4330.0

see image below the web page is there I cannot figure out how to debug this issue ?

125388-image.png

Developer technologies | .NET | Other
Developer technologies | ASP.NET | Other
{count} votes

Accepted answer
  1. rob m 261 Reputation points
    2021-08-31T01:22:19.843+00:00
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;
    
    namespace SWAT
    {
        public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                     "CountriesList",
                     "Location/Countries/List/{regionID}",
                     new { controller = "Location", action = "CountryList", regionID = UrlParameter.Optional }
                );
    
                routes.MapRoute(
                     "SubnationsList",
                     "Location/Subnations/List/{countryID}",
                     new { controller = "Location", action = "SubnationList", countryID = UrlParameter.Optional }
                );
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    //defaults: new { controller = "User", action = "Details", id = 191 }
                    defaults: new { controller = "User", action = "Details", id = 4 }
                    //defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
            }
        }
    }
    
    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Duane Arnold 3,216 Reputation points
    2021-08-23T21:43:57.327+00:00

    Are you sure the namespace for the view Details is viable and namespaces in the view are viable? What about in JavaScript pathing used by the view is viable?


  2. Yijing Sun-MSFT 7,096 Reputation points
    2021-08-24T06:50:38.117+00:00

    Hi @rob m ,
    As far as I think, the most common problem of 404 is your request URL isn't match the route url.
    If it is convenient, can you provide your routing configuration (RouteConfig)? By default,the url is like this

    "{controller}/{action}/{id}"  
    

    Through the information you provide, your request url is this:

    /User/Details/3  
    

    By the way,you should note wheather there are spelling errors.

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.