I am working on rewriting URLs Urlrewriting.net, and have run into what seems to be a common problem but I can seem to fix it. I'll present a simplified case.
The URL rewriting is working perfectly with the rule:
<urlrewritingnet rewriteOnlyVirtualUrls="true" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="catalog" virtualUrl="^~/catalog/(.*)/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/catalog.aspx?cid=$1&c=$2" ignoreCase="true"/>
</rewrites>
</urlrewritingnet>
On the page I have a DataList with 2 asp:buttons inside. When clicked, the page refreshes but does nothing.
I followed ScottGu's article to impliment a form control adapter to rewrite the action of the form to match the rewritten URL.
Page URL in the browser: http://...../dev/catalog/13/Music.aspx
<form name="aspnetForm" method="post" action="/dev/catalog/13/Music.aspx" id="aspnetForm">
I now see the correct URL on the form action, and when debugging I can see the page load event firing.
The problem now is that every time the page loads Page.IsPostback is false, causing the page to rebind the DataList and therefore ignore the ItemCommand the buttons should be triggering.
if (!Page.IsPostBack)
PopulateControls();
I'm using .NET 3.5 SP1, there is a ScriptManager on the master page but no UpdatePanel on this page. I've also tried resetting the Form.Action property and bypassing ScottGu's solution with the same result. If I go to the page URL directly without using the rewriter everything works fine.
What am I missing?