Summary:
If I have both these things:
- ASP.Net page Page1.aspx with Reponse.Redirect("/Page2.aspx") on the Page_Load event
- URL rewrite rule on IIS where "*/Page1.aspx" is redirected (303) to "/Page3.aspx"
What runs first, 1 or 2?
(ASP.Net version is 4.0, IIS version is 7.5)
Actual live case
http://inhibitif.com/product/Hair-Free-Deodorant
This route gets mapped to the page Product.aspx where Hair-Free-Face-Serum is the product key. If this page does not find the product key it redirects on the Page_Load event to the full products listing.
That specific key (Hair-Free-Deodorant) has changed (Hair-Free-Deodorant-Key-Lime-Mint-50ml) as per the site owner's request (out of my control). Consequently, any call to that specific product gets redirected to the full product listing (/products). Since, for SEO, it would be better to redirect to the new product page using the new key (as opposed to redirecting to a generic product listing page), I have added this rewrite rule on IIS
<rule name="Old Product Key: Hair-Free-Deodorant" patternSyntax="Wildcard" stopProcessing="true">
<match url="*/product/Hair-Free-Deodorant" />
<action type="Redirect" url="/product/Hair-Free-Deodorant-Key-Lime-Mint-50ml" />
</rule>
The rule never triggers. The redirect is always called.
- I know I can add this logic to the Page_Load event handler but, shouldn't it be the other way around? Should't the IIS rule get priority?
- Perhaps my rule is wrong?
Note: Rewrite rules are working on the site. For example, any call to "www.inhibitif.com" gets rewritten as "inhibitif.com"