user1817367
user1817367

Reputation: 43

Webservice not called in asp.net

I am having following ajax call in javascript

$.ajax({
    type: "Post",
    url: '../WebService/LoginService.asmx/LoginCheck',
    data: jsondata,
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    success: function (resp) {
        if (resp.d == true) {
            window.location.replace("../Admin/DashBoard.aspx");
            return;
        }
        jQuery("#lblex").css("display", "block");
    },
    error: function (response) {
        alert(response.responseText);
    }
});

This works fine at local when i test, but when i hosted this on my production server, it says service not found. But i am able to browse till the path

../WebService/LoginService.asmx

and if i change the url to

 ../WebService/LoginService.asmx?op = LoginCheck

it works there also.

Can anybody please let me know what configuration change i need to do at my local or at production server to get both of them working in same fashion

Upvotes: 0

Views: 441

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038780

If this script is inside a WebForm I would recommend you using the ResolveUrl method to ensure that proper url is generated no matter where your application is hosted:

url: '<%= ResolveUrl("~/WebService/LoginService.asmx/LoginCheck")',

If the script is not inside a WebForm but in a separate javascript file where you cannot use server side functions you could define a global javascript variable in your WebForm:

<script type="text/javascript">
    var serviceUrl = '<%= ResolveUrl("~/WebService/LoginService.asmx/LoginCheck")';
</script>

that you could later use in your separate js file:

url: serviceUrl,

Upvotes: 1

Related Questions