Hi,
WebMethod is not calling when I rewrite the urls using HttpModule. Could you please help me. These are my Codes
Client Side
function MyMethod() {
$.ajax({
type: 'POST',
url: 'Test.aspx/TestMethos',
async: true,
cache: true,
dataType: 'json',
contentType: 'application/json;charset=utf-8',
data: '{}',
success: function (data) {
},
error: function (request, status, error) {
if (request.statusText == 'Unauthorized') {
}
}
});
}
WebMethod
[WebMethod]
public static string TestMethod()
{
return "Hi Keedam";
}
HttpModule ReWrite C# Code
HttpApplication MyApp = (HttpApplication)sender;
string MyOldPath = MyApp.Request.Path;
string OriginalURL = string.Empty;
switch (MyOldPath.ToLower())
{
case "/home":
string selectedQueryString = MyApp.Request.QueryString.ToString();
OriginalURL = "~/Modules/UserMgmt/Home.aspx";
break;
case "/star performer":
OriginalURL = "~/Modules/UserMgmt/BestEmployee.aspx";
break;
case "/test.aspx/testmethod":
OriginalURL = "~/Modules/UserMgmt" + MyOldPath;
break;
}
if (OriginalURL != string.Empty)
MyApp.Context.RewritePath(OriginalURL, string.Empty, string.Empty);