views:

395

answers:

4

Hi,

i have the application on environment in IIS 5.1 under "localhost/mvcapplication1"

The routing configuration is something like:

    routes.MapRoute("mvc-default", "{controller}.mvc/{action}/{id}"
        , new { controller = "Home", action = "Index", id = (string)null });


    routes.MapRoute("Root", ""
        , new { controller = "Home", action = "Index", id = (string)null });

When the page is routed via "Root", the links on the views will point to

http://localhost/mvcapplication1/MvcApplication1/Product.mvc

, which obviously it doesn't exist. However when the first "mvc-default" is used, it works well.

If the application is hosted under http://......./ would also work well.

any hints about how to solve it?

Thanks.

+2  A: 

You're encountering 404 error because you've set the routing rule "{controller}.mvc/{action}/{id}", which obviously adds .mvc extension after the controller name, and the "" routing rule wouldn't take precede, even work because you're using unconfigured IIS.

To fix it without configuring IIS, you can change .mvc to something ASP.Net currently handles, like .aspx, .asmx, or something else.
If you want a fix for IIS, visit links below, follow the instructions, and remove the .mvc extension.

ASP.Net
Phil Haack's blog
You can find more posts about it if you just Google about it.

Parsa
A: 

Hi Parsa,

I guess you misunderstood me.

The routing to the extension "mvc" is working well, and the links work well on most of the cases.

It fails only when the application is hosted in iss(5.1) under something like: http://localhost/app, and the application uses the "Root" route (see above).

On this case a link generated via Html.ActionLink("Home", "Index", "Home"), will point to http://locahost/app/app/Home.mvc.

The actionLink appends on this case twice the relative path "app", which doesn't point to any valid url. I guess, the problem is a mistake on the routes configuration.

I saw already both links, but it didn't help me.

Thanks and regards.

A: 
Parsa
A: 

a year late, but maybe this will help someone else. i had the same issue, as we use IIS6, and i got it to work by having these two entries as the last two listed in my routing config:

            routes.MapRoute(null, "{controller}.aspx/{action}");
        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}.aspx/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

change the ".aspx" to your ".mvc" or whatever you need it to be.

Jamie M