weixin_33691598 2014-05-28 18:58 采纳率: 0%
浏览 42

SharePoint ASMX,AJAX

I have been working for a while now on a project that will be using JQueryUI autocompletes for user names (based on SPWeb.AllUsers) and will also be pulling content from a potentially large list separately in the same form. I initially attempted a page method and could not manage to get a return other than the whole page html (despite setting content type, etc), and so have moved on to attempting it via ASMX. The result of this is a 500. Running through Fiddler gave me the full ASP error: "The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators." I'm fairly certain the code inside the method is not being hit, as a breakpoint set on the first line of the method is not triggered.

Here's my web service:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class projectWebService : System.Web.Services.WebService
    public class person
        public person(string name, string company)
            this.name = name;
            this.company = company;

        public string name { get; set; }
        public string company { get; set; }

    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static string getNames()
            //Query list to filter by company and sort by name
            var userQuery = from SPUser user in SPContext.Current.Web.AllUsers
                            orderby user.Name ascending
                            select user;

            List<person> userList = new List<person>();
            foreach (SPUser user in userQuery)
                userList.Add(new person(user.Name, "something"));

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Serialize(userList);
        catch (Exception ex)
            return ex.Message;

I've tried a few variations on this with the same result. And here's the AJAX call:

        type: 'POST',
        dataType: 'json',
        data: '{}',
        contentType: 'application/json; charset=utf-8',
        url: 'projectWebService.asmx/getNames',
        success: function (msg) {
            var people = $.parseJSON(msg);
                source: people
        error: function (xhr, msg, error) {

Attempting to set "UseHttpGet" and making a GET request has been unsuccessful as well.

I found one related question here: This one mentions a web.config entry that may be the culprit. I have set this to no avail.

Also, this article covers other web.config changes that may(?) be required. This did not work for me, instead getting an ASP error for an invalid web.config.

I'm hoping someone has either had to deal with this before or sees something I do not. Thanks for any help!

  • 写回答

1条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 如何抓这个函数的包wx.updateShareMenu
      • ¥15 需要数据分析!时间紧!
      • ¥15 关于免费论文查重系统的问题。
      • ¥15 朋友们,这个sim函数是出了什么问题了呢
      • ¥15 【MRT数据导入问题】MRT处理modis数据提示opening input header file怎么解决?
      • ¥15 嵌入式系统综合设计题有会的教一下嘛?
      • ¥15 yolov5转onnx验证出错
      • ¥15 proteus仿真LCD不点亮
      • ¥15 C语言红绿灯时间问题
      • ¥15 matlab仿真实现定位算法