Purpose: I want to be able to type in the URL: www.mysite.com/NewYork OR www.mysite.com/name-of-business
Depending on the line, I want to redirect to different actions without changing the URL.
So far I:
public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute( "UrlRouter",
In the controller, I have:
public ActionResult TestRouting(string query) { if (query == "NewYork") return RedirectToAction("Index", "Availability"); // <--------- not sure else if (query == "name-of-business") return Redirect("nameofbusines.aspx?id=2731"); // <--------- not sure else return RedirectToAction("TestTabs", "Test"); // <--------- not sure }
I tried almost everything to redirect / redirect to the page without changing the URL, but everything I tried changes the URL or gives me an error.
Basically I am looking for the equivalent of server.transfer, where I can save the URL, but send the information to the action and show its result.
Cesarherrera
source share