0

I'm trying to rewrite the URL in my project and it works fine

Ex. the original URL is http://localhost:50260/u_SaleCom/Product.aspx?Status=Create and I rewrite it to http://localhost:50260/u_SaleCom/Product/Create by using code in web.config

 <system.webServer>
      <rewrite>
        <rules>
          <rule name="rewrite to u_SaleCom Product pages 1 QueryString" stopProcessing="true">
            <match url="^u_SaleCom/Product/([a-zA-Z0-9=]+)" />
            <action type="Rewrite" url="u_SaleCom/Product.aspx?Status={R:1}" />
          </rule>
        </rules>
      </rewrite>
    </system.webServer>

so until now everything works fine, but when page postback by clicking any button or using AutoPostBack in DropDownList the page URL will change to http://localhost:50260/u_SaleCom/Product/Create?Status=Create and that happens only if the URL is rewritten.

I try to search on the internet for a solution and I didn't find the right one.

I found here some questions with the same issue but also it's not helping me

ASP.NET postbacks creates issue in URL rewriting?

rewrite url. asp.net c#

PostBack Url in Rewriting Url using UrlRewriting.Net

Al-Hanashi
  • 33
  • 3
  • 14
  • Properties in the URL after the question mark are options so changing Status=Create to a subfolder /Create is wrong. You would need a new webpage called Create. – jdweng Nov 05 '17 at 07:14
  • sorry, @jdweng I didn't understand you, and I don't know if you understand me. I mention that webpage is work fine with the rewrite, the issue is when it postback – Al-Hanashi Nov 05 '17 at 07:18

1 Answers1

0

Try to use ,

$( window ).load(function() {Store Value Here }); 

The Rewrite URL Store in .load event Jquery and it will posses the value on post back.

Muhammad Ali
  • 129
  • 7