403 Forbidden Error
When I'm accessing web service from jquery, I'm getting the 403 forbidden error.. I published and created in the virtual directory too. Wat's the cause of this error and how to rectify it? I've added the webservice in the same solution.. This is my following code..
$(document).ready(function() {
$("#sayHelloButton").click(function(event){
开发者_如何学编程 $.ajax({
type: "POST",
url: "App_Code/DummyWebService.asmx/HelloToYou",
data: "{'name': '" + $('#name').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
AjaxSucceeded(msg);
},
error: AjaxFailed
});
});
});
function AjaxSucceeded(result) {
alert(result.d);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
I suppose using that url path for webservice is wrong.. I used the path 'DummyWebservice.asmx'. There I'm getting the 500 internal server error.
IIS and the dev server prevent access to your App_Code folder. This is where you should store your class files but your asmx needs to be in a publicly visible location.
Move your asmx into the root of your site but leave your asmx.cs in the App_Code so it is compiled.
Then obviously change the path in your JavaScript and give it a try.
精彩评论