1

I am fairly new to asp.net and I have a starting URL of http://localhost:61431/WebSuds/Suds/Welcome and routing code

       routes.MapRoute(
            "Default",                                 // Route name
            "{controller}/{action}/{page}",            // URL with parameters
            new { controller = "Suds", action = "Welcome", page = 1 }  // Parameter defaults
        );

        routes.MapRoute(
          "Single",
          "{controller}/{action}",
         new { controller = "Suds", action = "Welcome" }
        );

I am receiving the following error: 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.

Can anyone please help me figure out how to route the beginning url to the controller.

2
  • What does your websuds controller code look like? (that's what your URL is asking for) Commented Aug 22, 2010 at 20:00
  • Can you access any of your actions? If you remove the second route, does the problem persist? You may want to post the Welcome action of your SudsController, as there's nothing in the above that's inherently wrong. Commented Aug 22, 2010 at 20:26

3 Answers 3

1

Because the first part of your URL is WebSuds, the framework is trying to map the request to WebSudsController instead of SudsController. One thing you can try is to change the url parameter of your route to "WebSuds/{controller}/{action}".

Sign up to request clarification or add additional context in comments.

4 Comments

I think a better solution would be to set the VirtualPath of the application to /WebSuds; that way all routes would automatically ignore that part of the address.
@Ian. Good point. I agree that would be better assuming there aren't any other possible values that might be at that spot in the url.
I added "WebSuds/{controller}/{action}" to both of the routes and got the same error. I then added /WebSuds to the virtual path and received the same error
FYI: WebSuds is the application name
1

Route tables are searched on a first come first served basis. Once an appropriate match is found any following routes will be ignored.

You need to add "WebSuds/{controller}/{action}" and put it above the default route. The most specific routes should always go above the more generic ones.

11 Comments

Folks, I appreciate the help but have not had any success. Right now my virtual path is set to / and my routes to routes.MapRoute( "Single", "WebSuds/{controller}/{action}", new { controller = "Suds", action = "Welcome" } ); routes.MapRoute( "Default", "WebSuds/{controller}/{action}/{page}", new { controller = "Suds", action = "Welcome", page = 1 } ); and it still does not work. URL
The Error is 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: /WebSuds/Suds/Welcome
is it possible that this is not a routing issue?
BTW this application was not developed by me. I am trying to compile it and get it working. So is it possible that there are other factors affecting the routing?
and you have a controller called SudsController with a paramterless public method called Welcome()?
|
0

With the following Routes and Url you have given make sure you have these Methods in your Controller

public class SudsController
{
    public ActionResultWelcome(int? page) 
    {
        return View();
    }
}

Since you have created two routes of the same Action, one with a parameter page and another without. So I made the parameter int nullable. If you don't make your parameter in Welcome nullable it will return an error since Welcome is accepting an int and it will always look for a Url looks like this, /WebSuds/Suds/Welcome/1. You can also make your parameter as string to make your parameter nullable.

Then you should have this in your View Folder

Views
    Suds
        Welcome.aspx

If does doesn't exist, it will return a 404 error since you don't have a corresponding page in your Welcome ActionResult.

If all of this including what BritishDeveloper said. This should help you solve your problem.

1 Comment

Rob, I spoke with the developer of this app and he says that this is a working app. I have tried all that the BritishDeveloper suggests and yours above and none of these work. I have even removed the 2nd MapRoute that included the page=1. I do have the layout with the sudsController and the Welcome method that you talked about. It almost seems like the problem is related to something in the environment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.