Hello there, im having a little problem accomplishing this, hopefully someone can help me out. Currently using c#.
Goal: I want to be able to type URL: www.mysite.com/NewYork OR www.mysite.com/name-of-business
Depending on the string I want to route to different actions without changing the URL.
So far i have: In: public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute(
"UrlRouter", // Route name
"{query}", // URL with parameters
new { controller = "Routing", action = "TestRouting" } // Parameter defaults
);
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 have pretty much tried everything to redirect/transfer to the page without changing the URL, but everything i've tried changes the url or gives me an error.
Basically im looking for the equivalent of server.transfer where i can keep the url but send info to the action and have it display its result.
Any input would be appreciated.