gpt4 book ai didi

c# - 未将对象引用设置为对象(从 View 调用 Razor 模型)

转载 作者:太空狗 更新时间:2023-10-29 18:02:38 25 4
gpt4 key购买 nike

<分区>

使用 C# MVC4

我的看法:

@using Universe.Models
@model UserModel
@section css {
<link href="@Url.Content("~/Content/assets/charcreation.css")" rel="stylesheet"/>}
@using (Html.BeginForm("AddUser","Home", FormMethod.Post))
{

<div class="row-fluid">
<table id="tblBio">
<tr>
<td class="span3">
<span class="labeltext">Alias:</span>
</td>
<td class="span5">
@Html.TextBox(Model.Alias)
</td>
<td class="span4">
<span class="ui-state-highlight hidden"></span>
</td>
</tr>

我的模型:

public class UserModel
{
public int Id { get; set; }
public string Alias { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public bool IsExternal { get; set; }


public UserModel()
{

}

public UserModel(User user)
{
if (user == null) return;
Alias = user.Alias;
}
}

但是,我不断收到错误:

enter image description here

当我尝试调试它时,它甚至没有进入 Html.TextBox 方法或进入我的模型。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com