.net - Jquery Ajax call to url not working in ASP.NET -


i use ajax call in aspx page , use url rewrite. ajax call hit webmethod without url rewrite rule after applying rewrite rule stop working.

my aspx page ajax call is:

$.ajax({         type: "post",         url: "../cc/page.aspx/sendnewsletter",         data: d,         contenttype: "application/json; charset=utf-8",         datatype: "json",         success: function (response) {             alert('hi');             if (response.d == "1") {                 alert("newsletter has been sent successfully.");              }             else {                 alert("something went wrong.please try again later.");             }         },         failure: function (response) {             alert(response.d);         }     }).always(function () {      }); 

and webmethod is:

[webmethod] public static string sendnewsletter(string to, string newsletter, string newslettername) { } 

my rewrite rule is:

<rule name="rewrite normal cc request aspx">                 <match url="^cc/(.*)$" />                 <action type="rewrite" url="cc/{r:1}.aspx" />             </rule> 

your urlrewriterule turning original url /cc/page.aspx/sendnewsletter /cc/page.aspx/sendnewsletter.aspx

change rule following

<rule name="rewrite normal cc request aspx" stopprocessing="true">     <match url="^cc/([^/]*)/(.*)$" />     <action type="rewrite" url="cc/{r:1}.aspx/{r:2}" /> </rule> <rule name="rewrite normal cc" stopprocessing="true">     <match url="^cc/([^?]*)?(.*)$" />     <action type="rewrite" url="cc/{r:1}.aspx?{r:2}" /> </rule> 

and change url ../cc/page/sendnewsletter


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -