Htm.ActionLink Object reference not set to an instance of an object
I am getting this exception, i am not sure if im doing it the right way either,
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
The View
@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)
The error
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)
The controller
public ActionResult WoW(string realm, string chara)
{
var getchar = client.GetCharacter(realm, chara);
return View(getchar);
}
Any hints on what im doing wrong here would be greatly appreciate
the third argument is object routeValues
@Html.ActionLink("TextToBeDisplayed","ActionName",object routeValues, object htmlAttributes)
so in your case it becomes
@Html.ActionLink("Search", "WoW",new { controller = "Home", chara = Model.Name, realm = Model.Realm }, null)
精彩评论