views:

35

answers:

1

Let's say I have this Controller:

public class GlobalizationController : Controller
{
    public JavaScriptResult GlobalizedLabels(string virtualPath)
    {
        return new JavaScriptResult();
    }
}

I want the controller to handle (i.e. invoke from) any of the relative URLs below:

  • /globalization/~Enlargement/Controls/Container.ascx
  • /globalization/test/foobar.aspx
  • /globalization/HappyTimes/Are/Right/Now

What would my entry in global.asax routes.MapRoute() entry look like? As in...

        routes.MapRoute("Globalization", "globalization/{virtualPath}", new
        {
            controller = "Globalization", 
            action = "GlobalizedLabels" 
        });

The URL pattern "{virtualPath}" is wrong. What should it be?

A: 

First of all, Container.ascx is not a URL - its a user control. So that's not a valid URL.

You're trying to map routes to URL's which make no sense.

Before you try to register your routes, understand exactly what you're trying to achieve.

RPM1984
http://www.mysite.com/globalization/~Enlargement/Controls/Container.ascx isn't a URL? Click on the link! Sorry man, but it sounds like you don't know HTTP very well and you aren't experienced with MVC.
JamesBrownIsDead
Page Not Found - 404 Error PageThe page you are looking for (http://mysite.com/globalization/~Enlargement/Controls/Container.ascx) is not here.
RPM1984
I can only laugh dude.Im amazed that you think you can request a "User Control" as page.I think you're getting confused as to the difference between .ASPX and .ASCX.Either way, you need to go back to high school bro.
RPM1984