I have the following route
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Hotel", "en/hotels/{*hotelName}",
new { controller = "Hotel", action = "index" });
}
So the following URLs are routed
www.mydomain.com/en/hotels/my-hotel-name/
www.mydomain.com/en/hotels/myhotelname/
www.mydomain.com/en/hotels/my_hotel_name/
In my controller, I have a conditional check to see if the passed URL exists in my lookup table. For example
public class HotelController : Controller
{
[HttpGet]
[ActionName("Index")]
public ActionResult IndexGet(string hotelFolder)
{
if(CheckIfFolderExists(hotelFolder))
{
return Content("Hotel URL Found");
}
else
{
**//Here, I want to return the actual requested URL as it didn't exist in my lookup table
}
}
}
The routing is working in terms of the en/hotels path, if the incorrect URL is entered like below, the actual URL is just returned like normal.
www.mydomain.com/en/attractions/my-attraction-name/
Basically, I am wanting to build up a dictionary of URLs that I want to route, and if the requested URL doesn't exist in the dictionary I want to returned the requested URL whether that be a .HTM, .HTML or .ASP page.