Reputation: 2192
I have two map routes
routes.MapRoute(
name: "RawMode",
url: "raw/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, rawmode="1" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, rawmode = "0" }
);
The first route check for presence of "raw" word as part of url to enable raw mode of application. It all works fine. However, when I use RedirectToAction("Index","Home")
in some URL say http://domain/Home/TestPage
, it always take me to raw
mode of application detecting the first MapRoute
in sequence. i.e. to http://domain/raw/Home/Index
rather than http://domain/Home/Index
.
If I try to reverse the order of my map route, indeed rawmode
didn't work when called directly in browser like http://domain/raw/Home/Index
which is needed as well. How can I ensure that RedirectToAction
redirect to rawmode
only if I am rawmode
page and not in general view?
Upvotes: 0
Views: 215
Reputation: 18883
Use return RedirectToRoute("Default")
it will redirect you to
http://domain/Home/Index
Upvotes: 2