Using authentication / authorization of forms with rewritten URLs

I am doing a quick sandbox test with some rewritten URLs (example from Scott Guthrie's blog) and Forms Authentication / Authorization.

I have a very simple setup.

~/View/(\d{1,6})      =>      ~/Public/View.aspx?ContentID=$1

and

~/Buy/(\d{1,6})       =>      ~/Private/Purchase.aspx?ContentID=$1

I confirmed that URL rewriting works by looking at each of the following sections

Then I went and turned on my forms authentication / authorization for these 2 directories in Web.Config. Setting 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 fine when I look at 2 source URLs (an .aspx file) but it doesn't start at all when I look at URLs rewritten by versions.

<location> Buy , /.

, , URL ASPX... ,

    <LookFor>~/Buy/(\d{1,6})\.aspx</LookFor>

. ASPX , . , Auth url ( )

+3
4

auth, , "" URL- . , URL- , , "Public" 'Private'. URL-, , (, BeginRequest), web.config URL-.

, , URL-, , , .

. :

http://msdn.microsoft.com/en-us/library/ms972974.aspx

, .

+2

ASP.NET 4.0 ( , 3.5 SP1), . , ASP.NET, , .ASPX.

, .

0

, url , , , , , urlrewriter.net, ?

0

try enabling authentication and authorization for all requests. By default, it is enabled only for asp.net requests such as .aspx. It can be executed in IIS (7) or directly in web.config in the web server / modules section

<system.webServer>
   <modules>
        <remove name="FormsAuthentication" />
        <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition=""/>
        <remove name="UrlAuthorization" />
        <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" preCondition="" />
   </modules>
</system.webServer>
0
source

Source: https://habr.com/ru/post/1709601/


All Articles