Jarry Bruckheimer
Jarry Bruckheimer

Reputation: 17

IsPostBack returns always false when using urlrewriting

I created a very small web app. I want to use clean urls but if i use urlrewriting I can't reach PageMethods. I'm trying to reach PageMethods from a JavaScript file but isPostBack returns false and it just refreshes the page.

If i don't use urlrewriting it works perfectly and writes whatever i want to the writeHere div.

What could it be the problem ?

This is the ANCHOR that calls js function

Test <a href="#" onclick = "testjs('test');">HERE</a>. 
<div id = "writeHere"></div>

This is the JS FUNCTION that calls PageMethods

function testjs(test) {
document.getElementById("writeHere").innerHTML = "";

PageMethods.messi(test,CallSuccess,CallFailed);

function CallSuccess(res) {
    document.getElementById("writeHere").innerHTML = res.toString();
}

function CallFailed(res) {
   document.getElementById('writeHere').innerHTML = "ERROR";
   }
}

Here the MESSI METHOD of the aspx file

[System.Web.Services.WebMethod]
public static string messi(string test)
{
    return test; 
}

And finally this is the REWRITING RULE

<rewriter>
<rewrite url="~/(.+).aspx" to="~/uso/$1.aspx" processing ="stop"/>
</rewriter>

Any help would be appreciated.

Upvotes: 0

Views: 155

Answers (1)

Tomek
Tomek

Reputation: 3279

Not sure what rewriting engine you are using, make sure the query string is also carried over to rewritten URL. If PageMethods.messi is using GET verb to send the request, parameters informing that it is postback are in the query string.

Upvotes: 1

Related Questions