Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirect to controller (but with a different master) using a catchall wildcard
    text
    copied!<p>I have a problem whereby I want to display a view differently (a different master page), depending on where it came from, but don't know where to start...</p> <p>I have several routes which catch various different types of urls that contain different structures.</p> <p>In the code snippet below, I have a product route, and then I have a partner site route which could also go to a product page, but let's say that this partner is Pepsi, and they want their branding on the master page, rather than our own default styling. Lets say I go to <a href="http://mysite.com/products/cola.htm" rel="nofollow noreferrer">products/cola.htm</a>. This should go to the same url as <a href="http://mysite.com/partners/pepsi/products/cola.htm" rel="nofollow noreferrer">partners/pepsi/products/cola.htm</a>, and the PartnerRedirect would be able to handle the url based on the wildcard, by translating the url wildcard (in this case, "products/cola.htm") into a controller action, and forward the user on, (but simply change the master page in the view).</p> <pre><code>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" } ); </code></pre> <p>Is this possible? And if so, how?</p> <p>Many thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload