0
我得到这个例外的一个实例,我不知道如果IM要么做正确的方式,Htm.ActionLink对象引用未设置到对象
异常详细信息:System.NullReferenceException:对象引用未设置到一个对象的一个实例。
观
@model BattleNet.API.WoW.Character
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Character</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Realm)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Realm)
@Html.ValidationMessageFor(model => model.Realm)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<p>
<input type="submit" value="Search" />
</p>
</fieldset>
}
@Html.ActionLink("Search", "WoW", "Home", new { realm = Model.Realm, chara = Model.Name }, null)
错误
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 38: @Html.ActionLink("Search", "WoW", "Home", new { realm = Model.Realm, chara = Model.Name }, null)
控制器
public ActionResult WoW(string realm, string chara)
{
var getchar = client.GetCharacter(realm, chara);
return View(getchar);
}
在做什么,我错了这里将是任何提示非常感谢
我报复添加了控制器相同的异常:/ – Paragonbliss
那么我想你的模型中包含空值,试图通过一些静态字符串'chara =“Name”''realm =“realm”'看看它是否碰到了动作结果 – Rafay
我认为它真的很愚蠢,我应该用ajax.actionlink肩膀吗? theres没有一点使用模型,我不知道为什么我这样做,我只需要一个静态搜索页面,指向控制器与参数,真的很抱歉! – Paragonbliss