Note that there are some explanatory texts on larger screens.

plurals
  1. PORoute always goes to the first maproute
    primarykey
    data
    text
    <p>I'm trying to create URIs that look a little something like this: <code>http://hostname/mobile/en/controller/action</code> for mobiles OR <code>http://hostname/en/controller/action</code> for desktop (non mobiles).</p> <p>My Route table currently looks like this (Global.asax.cs)</p> <pre><code> routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Mobile", // Route name "mobile/{language}/{controller}/{action}/{id}", // URL with parameters new { language = "en", controller = "Route", action = "Index", id = UrlParameter.Optional }, // Parameter defaults new { language = @"en|us" } // validation ); routes.MapRoute( "Default", // Route name "{language}/{controller}/{action}/{id}", // URL with parameters new { language = "en", controller = "Route", action = "Index", id = UrlParameter.Optional }, // Parameter defaults new { language = @"en|us" } // validation ); </code></pre> <p>The problem occurs when I try to do a <code>return RedirectToAction("Add", "User");</code> It always redirects the desktop browser from <code>/en/User/List</code> to <code>/mobile/en/User/Add</code> when I want it to go to <code>/en/User/Add</code>. The Mobile version works correctly but I believe this is because the first "Mobile" route is always been seen to be the route that matches even if it doesn't have /mobile/ at the start.</p> <p>I'm trying to use the same <em>Controller</em> for both versions but am stuck at it always redirecting to the <em>Mobile</em> route. This means <code>RedirectToRoute</code> isn't prefect as I want dynamic routes.</p> <p>Thanks for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload