views:

240

answers:

1

I'm at a loss... here's my route:

routes.MapRoute("LangOnly", "{language}",
    new { controller = "Home", action = "Root", language = "en" },
    new { language = @"en|ja" });

it matches www.domain.com/en, but does not match www.domain.com/ja.

huh? I've even gone so far as to comment out any other routes... kind of stuck. ;/

Update: Here's the root action on the Home controller.

[CompressFilter]
public ActionResult Root()
{
    if (!IsEnglish)
        return RedirectToAction("Index", "Biz", new { b = "" });

    return Request.IsAuthenticated ? View("LoggedInRoot") : View("Root");
}

It doesn't take a language parameter because it's being set on the base controller in OnActionExecuting, like so:

    var l = (RouteData.Values["language"] != null) ? RouteData.Values["language"].ToString() : string.Empty;

    if (string.IsNullOrEmpty(l))
        l = "en";

    if (l.Contains("en"))
    {
        IsEnglish = true;
        l = "en";
    }
    else
    {
        IsEnglish = false;
        l = "ja";
    }

    ViewData["lang"] = l.ToLower();
    Language = l.ToLower();
+1  A: 

Works perfectly for me with your route. Try this simple configuration:

routes.MapRoute("LangOnly", "{language}",
                new {controller = "Home", action = "Index", language = "en"},
                new {language = @"en|ja"});


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

And your action:

public ActionResult Index(string language)
{
.....

(I am using "Index" as the action here, obviously change it to "Root" if that is in fact your action name.)

GONeale
found the error, redirect on the home/root action wasn't matching. ugh. thank you!
Chad