I have an ASP.NET website that uses URL rewrite rules for provides meaningful URLs. The URL:
www.example.com/folder/reports/{name}
is rewritten to:
www.example.com/index.aspx?Title={name}
Now, there is a linkbutton on the index.aspx page (doesn't have any code in the click event). When I click on the button, staying on the URL: www.example.com/folder/reports/{name}, instead of staying at the same URL after the post-back, it goes to the URL:
www.example.com/folder/reports/{name}?Title={name} and thus shows an error message.
Can someone please explain why the button-click is causing this wrong URL, even though a refresh on the page keeps me at the same page?
Here is my web.config rules configuration:
<rule name="Rewrite to page">
<match url="(.*)/reports/(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="(.*(\.html|\.htm|\.aspx)$)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.aspx?Title={R:2}" />
</rule>
I was able to clear this problem, by adding this line in the Page_Load event of the master-page:(where 'Form1' is the asp form used in the master-page)
Form1.Action = Request.RawUrl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With