ASP.Net url rewrite from …pdf to …aspx (IIS 7)

asp.netrewrite

I am trying to rewrite a url for a pdf to an aspx page it isn't working.
I doesen't see the request in my iis-log either.

<rewrite>
  <rules>
    <rule name="PDF" stopProcessing="true">
      <match url="PDF/(.*?)/(\d*)/(.*?.pdf)$" />
      <action type="Rewrite" url="SISPdf.aspx?id={R:2}&amp;fn={R:1}" logRewrittenUrl="true" />
    </rule>
  </rules>
</rewrite>

An example:

http://myserver:8089/PDF/ABC/123/DEF_456.pdf

should be rewritten to:

http://myserver:8089/SISPdf.aspx?id=123&fn=ABC

With all my attempts I get HTTP 500 or HTTP 404.

Is it possible to debug rewrite-rules?

Edit:

At the old IIS (<= 6) i remember me that i must set the ISAPI-Filter for ASP/ASP.Net on PDF or Image file extension so the IIS know that he must handle this. Is there any equivalent?

Best Answer

Try changing

<match url="PDF/(.*?)/(\d*)/(.*?.pdf)$" />

to

<match url="PDF/(.*)/(\d*)/(.*).pdf$" />

Also, take off "stopProcessing='true'". Since you're doing a rewrite, you would actually like to continue processing.