403 Forbidden Error

天涯浪子 提交于 2019-12-07 06:11:01

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/2167119/403-forbidden-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!