I have a problem where I want to display the view in a different way (another main page), depending on where it came from, but don’t know where to start ...
I have several routes that capture different types of URLs that contain different structures.
In the code snippet below, I have a product route, and then I have a partner route, which can also go to the product page, but let them say that this partner is Pepsi, and they want their branding on the main page, and not our own default style. Suppose I go to products / cola.htm . This should go to the same URL as partners / pepsi / products / cola.htm , and PartnerRedirect will be able to process the URL based on the pattern by translating the url (in this case, “products / cola.htm”) to controller action and redirect the user (but just change the main page in the view).
routes.MapRoute(
"Product",
"products/{product}.htm",
new { controller = "Product", action = "ShowProduct" }
);
routes.MapRoute(
"ProductReview",
"products/{product}/reviews.htm",
new { controller = "Product", action = "ShowProductReview" }
);
routes.MapRoute(
"Partner",
"partners/{partner}/{*wildcard}",
new { controller = "Partners", action = "PartnerRedirect" }
);
Is it possible? And if so, how?
Thank you very much in advance.
source
share