views:

447

answers:

2

I'm seeing a difference in the output from Url.RouteUrl between my development machine and my deployment server. I'm running Visual Studio 2008 and my deployment box is Windows 2003 Server. I have configured the Global.asax.cs to run with the .aspx extension in my routing tables. However, when I use the "Search-Basic" named route, there is no output from Url.RouteUrl("Search-Basic", new {category = "Test", searchExpression = "search this"})

View Code:

<%= Url.RouteUrl("Search-Basic", new {category = "test", searchExpression="search this"}) %>

Global.asax.cs Code:

            // routes for IIS 6 and version below
        routes.MapRoute(
            "Search-Basic",
            "Search.aspx/Basic/{category}",
            new { controller = "Search", action = "Basic", category = "All" }
            );

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

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

On my development box, I get the expected output: /Search.aspx/Basic/Test?searchExpression=search%20this

However, on my deployment server I get no output at all. One difference perhaps is that I'm running the application in a virtual directory on my deployment server; something like: http://testmachine.com/sm/testappname/ where "/sm" is a virtual directory and "/testappname" is a virtual directory holding my application.

Any ideas?

Thank you kindly.

+1  A: 

Are you running the same version of ASP.NET MVC because there is a bug in the RC1 (non-refresh) that causes this behavious when you have a route where e.g. the controller is not specified in the route:

The other regression is that in some cases, the RouteUrl (and thus RouteLink) methods return an empty string when you specify a route name, but the route has default parameters which are not parameters in the URL.

For example, if you have the following route:

routes.MapRoute("route-name", "foo/bar", new {controller="Home", action="index"});

Notice that controller has default value, but is not part of the URL. If you then specify:

<%= Url.RouteUrl("route-name") %>

You might expect that it would use that route to render the URL, but it doesn’t. This bug was introduced when we refactored all our url generating helpers to call into a common method. It turns out, however, that our RouteUrl methods (aka non-MVC specific) should have subtly different behavior than the MVC specific methods (such as Action). We added a flag to the common method so that this difference is taken into consideration. This was a fix that did not have a large surface area.

See http://haacked.com/archive/2009/01/30/aspnetmvc-refresh.aspx

veggerby
I'm having my installer check the date on the signature. Good suggestion, could be the cause. Also, if let the normal default.aspx implementation run, I get some doubling of url path parts, like testserver.com/sm/testappname/testappname when ever I run Html.ActionLink or Url.RouteUrl.
Cole B
Sorry, even with the new refresh RC1, it didn't fix the problem. I'm still investigating though. Thank you for the suggestion.
Cole B
Okay, these errors may not even be related to MVC. Seems as if my development server configuration /sm virtual directory isn't a virtual directory at all. Or at least it is defined as an IIsConfigObject in IIS 6. This seems to be the cause of my differences in URL output.
Cole B
A: 

Okay, I believe I have narrowed the problem down to an unusal configuration in IIS 6. I have asked a question here.

Both suggestions of making sure I was updated to the Refresh of RC1 and utilizing the Routing Debugging from Haack lead me down this path as they both eliminated the version and routing problems.

Cole B