: ISAPI_Rewrite and asp.net events upon postback I have a rewrite rule to rewrite www.mysite.com/default.aspx to www.mysite.com. RewriteRule ^default.aspx$ / [NC,R=301,L] On that site i have an asp.net
I have a rewrite rule to rewrite mysite.com/default.aspx to mysite.com.
RewriteRule ^default.aspx$ / [NC,R=301,L]
On that site i have an asp.net server Button. When i click the button it tries to go to postback to default.aspx, but gets 301'd to the root. This prevents the button's click event from triggering.
How can i redirect default.aspx, without breaking my button's event?
More posts by @Angie530
1 Comments
Sorted by latest first Latest Oldest Best
You can add this condition RewriteCond %{REQUEST_METHOD} ^GET$ just before rewrite rule to redirect only on GET requests:
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteRule ^default.aspx$ / [NC,R=301,L]
This will allow to POST to default.aspx .. but then it will not be redirected at all.
Ideally you would need to fix your server side / HTML: look at your <form action"XXX"> -- change action to / instead of default.aspx (P.S. I'm not familiar with ASP.NET much and cannot 100% that this is how .NET really works, but this is the way how you can fix it if it would be PHP, for example). The idea is -- fix the source of the problem -- so the form gets submitted to / in first place.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.