C# Can';在MVC 5视图中看不到我的控制器对象

C# Can';在MVC 5视图中看不到我的控制器对象,c#,jquery,asp.net-mvc,model-view-controller,C#,Jquery,Asp.net Mvc,Model View Controller,我是MVC新手,我正在用这项技术编写我的第一个应用程序。 我试图将一个对象从控制器返回到我的视图,但我在视图中看不到它,这是我的控制器代码: ` public ActionResult Create(int id) { AddAffiliatModel serverUsersModel = new AddAffiliatModel(); ObjectResult<getServerUsers_Result> serverUsers =

我是MVC新手,我正在用这项技术编写我的第一个应用程序。 我试图将一个对象从控制器返回到我的视图,但我在视图中看不到它,这是我的控制器代码:

` 
   public ActionResult Create(int id)
    {
        AddAffiliatModel serverUsersModel = new AddAffiliatModel();
        ObjectResult<getServerUsers_Result> serverUsers = serverUsersModel.getSUsers(); 
        List<getServerUsers_Result> users = serverUsers.ToList();
        return View(users[0]);
    }` 
`
公共操作结果创建(int id)
{
AddAffiliatModel serverUsersModel=新的AddAffiliatModel();
ObjectResult serverUsers=serverUsersModel.getSUsers();
List users=serverUsers.ToList();
返回视图(用户[0]);
}` 
这是我的视图代码:

            @model MVC_5_Skeleton1.Models.getServerUsers_Result
        <!DOCTYPE html>

        <html>
        <head>
            <meta name="viewport" content="width=device-width" />
            <title>getUsers</title>
            <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
            <script src="~/JS/AddAffiliate.js"></script>
            <style>
                .txtW {
                    max-width: 300px;
                }

                .txtAH {
                    height: 200PX;
                }
            </style>
            <script type="text/javascript">
                //**************************************************************************
                //** Jquery Ready function hooks the buttons click events                  *
                //**************************************************************************
                $(document).ready(function () {


                    $(document).on('click', 'button', function (e) {
                        buttonId = $(this).attr("id");
                        switch (buttonId) {
                            case "submit":
                                Validate();
                                clearFields();
                                break;
                            case "cancel":

                                break;

                            default:
                                break;
                        }

                    });
                });
                //**************************************************************************
                //** Validate and send                                                     *
                //**************************************************************************
                function SendToServer() {

                }
                //**************************************************************************
                //** Validate and send                                                     *
                //**************************************************************************
                function Validate() {
                    var errorMsg = "";
                    var postString = "";
                    var valid = 0;
                    var filter = /^([a-zA-Z0-9_\.\-])+\@@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

                    if ($('#fullName').val().length > 2) {
                        var name = $('#fullName').val();

                    }
                    else {
                        errorMsg = 'Please enter name';
                        valid = 1;
                    }
                    if ($('#email').val().length > 5) {

                        var email = $('#email').val();
                    }
                    else {
                        errorMsg += 'Please valid email' + '/n';
                        valid = 1;
                    }
                    if ($('#skype').val().length > 3) {
                        var name = $('#skype').val();

                    }
                    else {
                        errorMsg = 'Please Skype name' + '/n';
                        valid = 1;
                    }
                    if ($('#Countries-leagues').val().length > 5) {
                        var cl = $('#Countries-leagues').val()
                    }
                    else {
                        errorMsg = 'Please enter Coverage' + '/n';
                        valid = 1;
                    }
                    if ($('#opinion').val().length > 5) {
                        var opinion = $('#opinion').val()
                    }
                    else {
                        errorMsg = 'Please enter Coverage' + '/n';
                        valid = 1;
                    }
                    if (valid == 0) {
                        send();
                    }
                }
                //**************************************************************************
                //** Get desired length and string to chech                                *
                //**************************************************************************
                function Send() {
                    AffiliateData.pType = 'AddAffiliate';
                    AffiliateData.user[0].recomanderId = "1"
                    AffiliateData.user[0].userName = $('#fullName').val();
                    AffiliateData.user[0].email = $('#email').val();
                    AffiliateData.user[0].skype = $('#skype').val();
                    AffiliateData.user[0].covered = $('#Countries-leagues').val();
                    AffiliateData.user[0].opinion = $('#opinion').val();
                    if ($('#canConnect').is(":checked")) {
                        AffiliateData.user[0].canContact = "1";
                    }
                    else {
                        AffiliateData.user[0].canContact = "0";
                    }
                    if ($('#aware').is(":checked")) {
                        AffiliateData.user[0].aware = "1";
                    }
                    else {
                        AffiliateData.user[0].aware = "0";
                    }
                    $.ajax({
                        type: "POST",
                        processData: false,
                        url: "http://localhost/MVC%205%20Skeleton1/AddAffilate/Create/1",
                        // The key needs to match your method's input parameter (case-sensitive).
                        data: JSON.stringify({ json: AffiliateData }),
                        //    dataType: "json",
                        success: function (data) {
                            alert(data);
                        },
                        failure: function (errMsg) {
                            alert(errMsg);
                        }
                    });
                }
                //**************************************************************************
                //** Clean UI Fields                                                       *
                //**************************************************************************
                function clearFields() {

                    $('#fullName').val("");
                    $('#email').val("");
                    $('#skype').val("");
                    $('#email').val("");
                    $('#Countries-leagues').val("");
                    $('#opinion').val("");
                    $('input:checkbox').removeAttr('checked');
                }
                //*********************      end of script block       *********************
            </script>
        </head>
        <body>
            <h2>Create new Affilate</h2>

            <fieldset>

                <!-- Form Name -->
                <!-- Text input-->
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="control-label" for="textinput">Candidate Name </label>
                    </div>
                    <div class="col-md-12">
                        <input id="fullName" name="textinput" type="text" placeholder="Candidate Name " class="form-control input-md txtW" required="">
                    </div>
                </div>
                <!-- Text input-->
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="control-label" for="email">Email</label>
                    </div>
                    <div class="col-md-12">
                        <input id="email" name="email" type="email" placeholder="Email" class="form-control input-md txtW" required="">
                    </div>
                </div>
                <!-- Text input-->
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="control-label" for="skype">Skype</label>
                    </div>
                    <div class="col-md-12">
                        <input id="skype" name="skype" type="text" placeholder="Skype" class="form-control input-md txtW" required="">

                    </div>
                </div>

                <!-- Textarea -->
                <div class="form-group">
                    <label class="col-md-12 control-label" for="Countries-leagues">Countries/leagues</label>
                    <div class="col-md-12">
                        <textarea class="form-control txtW txtAH" id="Countries-leagues" name="Countries-leagues" required=""></textarea>
                    </div>
                </div>

                <!-- Textarea -->
                <div class="form-group">
                    <label class="col-md-12 control-label" for="opinion">Way are you recommending Him/Her</label>
                    <div class="col-md-4">
                        <textarea class="form-control txtW txtAH" id="opinion" name="opinion" required=""></textarea>
                    </div>
                </div>

                <!-- Multiple Checkboxes -->
                <div class="form-group">
                    <label class="col-md-12 control-label" for="checkboxes"></label>
                    <div class="col-md-4">
                        <div class="checkbox">
                            <label for="checkboxes-0">
                                <input type="checkbox" name="checkboxes" id="canConnect" value="0">
                                Can we contact he/she?
                            </label>
                        </div>
                        <div class="checkbox">
                            <label for="checkboxes-1">
                                <input type="checkbox" name="checkboxes" id="aware" value="0">
                                Dose he/she knows will approach them?
                            </label>
                        </div>
                    </div>
                </div>

                <!-- Button (Double) -->
                <div class="form-group">
                    <label class="col-md-12 control-label" for="submit"></label>
                    <div class="col-md-8">
                        <button id="submit" name="submit" class="btn btn-success">Submit</button>
                        <button id="cancel" name="cancel" class="btn btn-primary">Cancel</button>
                    </div>
                </div>

            </fieldset>
        </body>
        </html>
@model MVC\u 5\u Skeleton1.Models.getServerUsers\u结果
getUsers
.txtW{
最大宽度:300px;
}
txtAH先生{
高度:200PX;
}
//**************************************************************************
//**jqueryready函数钩住按钮单击事件*
//**************************************************************************
$(文档).ready(函数(){
$(文档)。在('click','button',函数(e)上{
buttonId=$(this.attr(“id”);
开关(按钮NID){
案例“提交”:
验证();
clearFields();
打破
“取消”案例:
打破
违约:
打破
}
});
});
//**************************************************************************
//**验证并发送*
//**************************************************************************
函数SendToServer(){
}
//**************************************************************************
//**验证并发送*
//**************************************************************************
函数验证(){
var errorMsg=“”;
var postString=“”;
var valid=0;
变量过滤器=/^([a-zA-Z0-9\.\-])+\@([a-zA-Z0-9\-])+)+([a-zA-Z0-9]{2,4})+$/;
if($('#fullName').val().length>2){
var name=$('#fullName').val();
}
否则{
errorMsg='请输入名称';
有效=1;
}
如果($('#email').val().length>5){
var email=$('#email').val();
}
否则{
errorMsg+='请发送有效电子邮件'+'/n';
有效=1;
}
如果($('#skype').val().length>3){
var name=$('#skype').val();
}
否则{
errorMsg='请使用Skype名称'+'/n';
有效=1;
}
如果($(“#国家联盟”).val().length>5){
var cl=$(“#国家联盟”).val()
}
否则{
errorMsg='请输入覆盖范围'+'/n';
有效=1;
}
如果($(“#意见”).val().length>5){
var意见=$(“#意见”).val()
}
否则{
errorMsg='请输入覆盖范围'+'/n';
有效=1;
}
如果(有效==0){
send();
}
}
//**************************************************************************
//**获取要检查的所需长度和字符串*
//**************************************************************************
函数Send(){
AffiliateData.pType='AddAffiliate';
AffiliatedData.user[0]。recomanderId=“1”
AffiliatedData.user[0]。用户名=$(“#全名”).val();
AffiliatedData.user[0]。电子邮件=$(“#电子邮件”).val();
AffiliatedData.user[0]。skype=$(“#skype”).val();
AffiliatedData.user[0]。covered=$(“#国家联盟”).val();
AffiliateData.user[0]。意见=$(“#意见”).val();
如果($('#canConnect')。为(“:选中”)){
AffiliatedData.user[0].canContact=“1”;
}
否则{
AffiliatedData.user[0].canContact=“0”;
}
如果($('#aware')。是(“:checked”)){
AffiliatedData.user[0]。aware=“1”;
}
否则{
用户[0].aware=“0”;
}
$.ajax({
类型:“POST”,
processData:false,
url:“http://localhost/MVC%205%20Skeleton1/AddAffilate/Create/1",
//键需要与方法的输入参数匹配(区分大小写)。
数据:JSON.stringify({JSON:AffiliateData}),
//数据类型:“json”,
成功:功能(da)
 <textarea class="form-control txtW txtAH" id="opinion" name="opinion" required="">@Model.opinion</textarea>
$("#opinion").val()