Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 选择不发布信息MVC标识_C#_Html_Asp.net Mvc_Model View Controller_Asp.net Identity - Fatal编程技术网

C# 选择不发布信息MVC标识

C# 选择不发布信息MVC标识,c#,html,asp.net-mvc,model-view-controller,asp.net-identity,C#,Html,Asp.net Mvc,Model View Controller,Asp.net Identity,我已经为我的MVC web应用程序创建了一个注册页面。当我尝试注册用户时,cuisine_1、cuisine_2和cuisine_3选择框中的信息不会输入UserCuisineInfo表。但是,会创建一个带有id的新行,并且网页上会显示一条错误消息,指出需要使用Council_1、Council_2和Council_3字段 注册网页 @model Bitev2.Models.RegisterViewModel @{ ViewBag.Title = "Register"; } <h

我已经为我的MVC web应用程序创建了一个注册页面。当我尝试注册用户时,cuisine_1、cuisine_2和cuisine_3选择框中的信息不会输入UserCuisineInfo表。但是,会创建一个带有id的新行,并且网页上会显示一条错误消息,指出需要使用Council_1、Council_2和Council_3字段

注册网页

@model Bitev2.Models.RegisterViewModel
@{
    ViewBag.Title = "Register";
}

<h2>@ViewBag.Title.</h2>

@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    @Html.AntiForgeryToken()
    <h4>Create a new account.</h4>
    <hr />
    @Html.ValidationSummary()
    <div class="form-group">
        @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
        </div>
    </div>
    <div class="form-group">
    @Html.LabelFor(m => m.FirstName, new { @class = "col-md-2 control-label" })
    <div class="col-md-10">
        @Html.TextBoxFor(m => m.FirstName, new { @class = "form-control" })
    </div>
</div>
<div class="form-group">
    @Html.LabelFor(m => m.LastName, new { @class = "col-md-2 control-label" })
    <div class="col-md-10">
        @Html.TextBoxFor(m => m.LastName, new { @class = "form-control" })
    </div>
</div>
    <div class="form-group">
        @Html.LabelFor(m => m.Gender, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.DropDownList("Gender", new SelectList(new[] {"Female", "Male"}))
        </div>
    </div>
    <div class="form-group">
    @Html.LabelFor(m => m.DateofBirth, new { @class = "col-md-2 control-label" })
    <div class="col-md-10">
        @Html.TextBoxFor(m => m.DateofBirth, new { @class = "form-control", @InputType = "date" })
    </div>
</div>
<div class="form-group">
    @Html.LabelFor(m => m.EmailID, new { @class = "col-md-2 control-label" })
    <div class="col-md-10">
        @Html.TextBoxFor(m => m.EmailID, new { @class = "form-control" })
    </div>
</div>
    <div class="form-group">
            @Html.LabelFor(m => m.Cuisine_1, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.DropDownList("Cuisine", new SelectList(new[] { "African", "American",
               "Asian", "Bakery", "British", "Carribean", "Chinese", "Continetal", "Eastern European", 
               "French", "German", "Greek", "Indian", "Irish", "Italian", "Japanese", "Mediteranean", 
               "Mexican", "Middle Eastern", "Pizza", "Pub", "Steakhouse", "Sushi", "Thai", "Vegetarian", 
               "Vietnamese"  }))
            </div>
        </div>
    <div class="form-group">
            @Html.LabelFor(m => m.Cuisine_2, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.DropDownList("Cuisine", new SelectList(new[] { "African", "American", 
               "Asian", "Bakery", "British", "Carribean", "Chinese", "Continetal", "Eastern European", 
               "French", "German", "Greek", "Indian", "Irish", "Italian", "Japanese", "Mediteranean",
               "Mexican", "Middle Eastern", "Pizza", "Pub", "Steakhouse", "Sushi", "Thai", "Vegetarian", 
               "Vietnamese"  }))
            </div>
        </div>
    <div class="form-group">
            @Html.LabelFor(m => m.Cuisine_3, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.DropDownList("Cuisine", new SelectList(new[] { "African", "American", 
               "Asian", "Bakery", "British", "Carribean", "Chinese", "Continetal", "Eastern European", 
               "French", "German", "Greek", "Indian", "Irish", "Italian", "Japanese", "Mediteranean",
               "Mexican", "Middle Eastern", "Pizza", "Pub", "Steakhouse", "Sushi", "Thai", "Vegetarian", 
               "Vietnamese"  }))
            </div>
        </div>
    <div class="form-group">
        @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
        </div>
    </div>
    <div class="form-group">
        @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" class="btn btn-default" value="Register" />
        </div>
    </div>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
帐户控制器注册表视图

// POST: /Account/Register
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser() { UserName = model.UserName, FirstName = model.FirstName, LastName = model.LastName, EmailID = model.EmailID, Gender = model.Gender, DateofBirth = model.DateofBirth,
                UserCuisineInfo = new UserCuisineInfo
                {
                    Cuisine_1 = model.Cuisine_1,
                    Cuisine_2 = model.Cuisine_2,
                    Cuisine_3 = model.Cuisine_3
                }
                };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInAsync(user, isPersistent: false);
                    return RedirectToAction("Index", "Profile");
                }
                else
                {
                    AddErrors(result);
                }
            }
用户菜系信息

public class UserCuisineInfo
    {
        public int Id { get; set; }
        public string Cuisine_1 { get; set; }
        public string Cuisine_2 { get; set; }
        public string Cuisine_3 { get; set; }
    }

你给你所有的下拉菜单起了一个烹饪的名字。您需要将它们更改为“烹饪1”、“烹饪2”和“烹饪3”。

您为所有下拉菜单都指定了一个烹饪名称。您需要将它们更改为“烹饪1”、“烹饪2”和“烹饪3”。

您为所有下拉菜单都指定了一个烹饪名称。您需要将它们更改为“烹饪1”、“烹饪2”和“烹饪3”。

您为所有下拉菜单都指定了一个烹饪名称。您需要将它们更改为Council_1、Council_2和Council_3。

您有三个名称相同的下拉列表,称为
Council
。更新它们,使其反映模型上的特性:

 @Html.DropDownList("Cuisine_1", ...

 @Html.DropDownList("Cuisine_2", ...

 @Html.DropDownList("Cuisine_3", ...
呈现这些控件时,它们将生成一个表单控件,如:

<select name="Cuisine_1" ....

您有三个名称相同的下拉列表,称为
美食
。更新它们,使其反映模型上的特性:

 @Html.DropDownList("Cuisine_1", ...

 @Html.DropDownList("Cuisine_2", ...

 @Html.DropDownList("Cuisine_3", ...
呈现这些控件时,它们将生成一个表单控件,如:

<select name="Cuisine_1" ....

您有三个名称相同的下拉列表,称为
美食
。更新它们,使其反映模型上的特性:

 @Html.DropDownList("Cuisine_1", ...

 @Html.DropDownList("Cuisine_2", ...

 @Html.DropDownList("Cuisine_3", ...
呈现这些控件时,它们将生成一个表单控件,如:

<select name="Cuisine_1" ....

您有三个名称相同的下拉列表,称为
美食
。更新它们,使其反映模型上的特性:

 @Html.DropDownList("Cuisine_1", ...

 @Html.DropDownList("Cuisine_2", ...

 @Html.DropDownList("Cuisine_3", ...
呈现这些控件时,它们将生成一个表单控件,如:

<select name="Cuisine_1" ....