I'm doing a quick sandbox test with some Rewritten URLs (example taken from Scott Guthrie's blog) and Forms Authentication / Authorization.
I've a very simple setup.
~/View/(\d{1,6}) => ~/Public/View.aspx?ContentID=$1
AND
~/Buy/(\d{1,6}) => ~/Private/Purchase.aspx?ContentID=$1
I've confirmed the URL Rewriting is working by browsing to each of the following seperately
- http://localhost/urltest/Public/View.aspx?contentID=123456
- http://localhost/urltest/View/123456
- http://localhost/urltest/Private/Purchase.aspx?contentID=123456
- http://localhost/urltest/Buy/123456
Next I went and enabled my Forms Authentication/Authorization for those 2 directories in the Web.Config. Setup as follows
<location path="Private">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<location path="Public">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
This works perfectly when I browse to the 2 original URLs (the .aspx's) but doesn't fire at all when I browse to the URL Rewritten versions.
I've attempted to add <location>
sections for Buy
seperately but this still fails to cause the authorization/authentication module to kick in.
Presumably this is because it isn't treating these URLs as ASPX Resources... I can get around it by making the rewriter rule look for
<LookFor>~/Buy/(\d{1,6})\.aspx</LookFor>
i.e. force the rewritten version to have an ASPX at the end, but this just seems ugly. Is there anyway to get the Auth Handlers to fire for any url type regardless of the extension (or lack there of)