tags:

views:

59

answers:

3

Hi,

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.

+1  A: 

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}".

Bryan
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 Henry
@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.
Bryan
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
kreljm
FYI: WebSuds is the application name
kreljm
+1  A: 

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.

BritishDeveloper
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
kreljm
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
kreljm
is it possible that this is not a routing issue?
kreljm
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?
kreljm
and you have a controller called SudsController with a paramterless public method called Welcome()?
BritishDeveloper
There is a controller called SudsController with a method called Welcome. public ActionResult Welcome()
kreljm
Yeah, it's not your route then. have you installed ASP.NET MVC 2? Do you have System.Web.Routing.dll in your web root's bin? Have you set <system.webServer> <modules runAllManagedModulesForAllRequests="true"> in the web.config?
BritishDeveloper
I have installed asp.net mvc 1 and have references to it. I have a reference to :\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Routing.dll
kreljm
Here are my web.config WebServer settings. <system.webServer> <modules runAllManagedModulesForAllRequests="true"> <remove name="ScriptModule"/><remove name="UrlRoutingModule"/> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>
kreljm
add precondition="" to all of those modules
BritishDeveloper
This was not successful
kreljm
I do appreciate all of your help!
kreljm
A: 

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.

rob waminal
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.
kreljm