Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Forms Authentication/Authorization with Rewritten URLs
    primarykey
    data
    text
    <p>I'm doing a quick sandbox test with some Rewritten URLs (example taken from Scott Guthrie's blog) and Forms Authentication / Authorization.</p> <p>I've a very simple setup.</p> <pre><code>~/View/(\d{1,6}) =&gt; ~/Public/View.aspx?ContentID=$1 </code></pre> <p>AND</p> <pre><code>~/Buy/(\d{1,6}) =&gt; ~/Private/Purchase.aspx?ContentID=$1 </code></pre> <p>I've confirmed the URL Rewriting is working by browsing to each of the following seperately</p> <ul> <li><a href="http://localhost/urltest/Public/View.aspx?contentID=123456" rel="nofollow noreferrer">http://localhost/urltest/Public/View.aspx?contentID=123456</a></li> <li><a href="http://localhost/urltest/View/123456" rel="nofollow noreferrer">http://localhost/urltest/View/123456</a> </li> <li><a href="http://localhost/urltest/Private/Purchase.aspx?contentID=123456" rel="nofollow noreferrer">http://localhost/urltest/Private/Purchase.aspx?contentID=123456</a></li> <li><a href="http://localhost/urltest/Buy/123456" rel="nofollow noreferrer">http://localhost/urltest/Buy/123456</a></li> </ul> <p>Next I went and enabled my Forms Authentication/Authorization for those 2 directories in the Web.Config. Setup as follows</p> <pre><code> &lt;location path="Private"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;deny users="?" /&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path="Public"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow users="*" /&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; </code></pre> <p>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.</p> <p>I've attempted to add <code>&lt;location&gt;</code> sections for <code>Buy</code> seperately but this still fails to cause the authorization/authentication module to kick in.</p> <p>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</p> <pre><code> &lt;LookFor&gt;~/Buy/(\d{1,6})\.aspx&lt;/LookFor&gt; </code></pre> <p>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)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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