400(错误请求)错误:从主干模型调用WCF.net服务';基础设施

400(错误请求)错误:从主干模型调用WCF.net服务';基础设施,.net,wcf,backbone.js,requirejs,.net,Wcf,Backbone.js,Requirejs,我正试图建立我的第一个主干模型来实现RESTful WCF服务。到目前为止,我的路由器创建了用户模型,我只想执行fetch()。我创建了一个虚拟Web服务,只是为了在纠正我的实际WS代码之前尝试让它运行起来 编辑:我认为这是我的web.config的一个问题,不确定我需要什么 我的路由器: define([ 'backbone', 'dashboard', 'models/UserModel' ], function(Backbone, Dashboard, User

我正试图建立我的第一个主干模型来实现RESTful WCF服务。到目前为止,我的路由器创建了用户模型,我只想执行fetch()。我创建了一个虚拟Web服务,只是为了在纠正我的实际WS代码之前尝试让它运行起来

编辑:我认为这是我的web.config的一个问题,不确定我需要什么

我的路由器:

define([
    'backbone', 
    'dashboard',
    'models/UserModel'
], 
function(Backbone, Dashboard, UserModel) {
    var homeRouter = Backbone.Router.extend({
        initialize : function() {
            Backbone.history.start();           
        },

        routes : {
            '' : 'home',
            'docs': 'docs'

        },

        'home' : function() {

            var user = new UserModel({userId: 'cjestes'});
            user.fetch();

        },

        'docs' : function() {
            //load docs page

        }

    });

    return new homeRouter();
});
我的模型:

define([
    'jquery',
    'backbone'
], 
function($, Backbone) {
    //Docs Metro View
    var userModel = Backbone.Model.extend({
        userId: " ",

        url:  "services/User.svc/GetUserInformation",

        initialize: function () {

            this.userId = this.get("id");

        }

    });

    // Return the Docs Model
    return userModel;
});
我的SVC:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.Web.Hosting;
using System.Collections.Specialized;


namespace Mri.Dashboard.services
{

    public class User : IUser
    {
        public string GetUserInformation()
        {
            return "hello";

        }
    }
}
我的界面

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Web;

namespace Mri.Dashboard.services
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IUser" in both code and config file together.
    [ServiceContract]
    public interface IUser
    {
        [OperationContract]
        string GetUserInformation();
    }
}

对于任何偶然发现这一点的人,我最终使用了一个.svc/config-less WCF实现。我从这个模板开始,它列出了您需要做的一切,让REST WCF启动并运行


我能够将此模板与主干模型的内置同步一起使用,这非常容易操作和使用

似乎您尚未使用[WebGet]属性对服务合同进行批注!为了使用REST wcf,您需要通过UriTemplate=“GetUserInformation”这样的方式将OperationContract映射到URI:[WebInvoke(UriTemplate=“GetUserInformation”)]