我具有控制器列出如下:净MVC视图不渲染
//
// GET: /Customer/Details/5
public ActionResult Details(short id)
{
ActionResult actionResult = null;
if (HttpContext.User.IsInRole("Admin"))
{
// this is the logic that is getting executed
YeagerTechWcfService.Customer cust = db.GetCustomerID(Convert.ToInt16(id));
actionResult = View("Details", cust); }
else
{
HttpCookie cn = Request.Cookies["strCookieName"];
if (cn != null)
{
YeagerTechWcfService.Customer cust = db.GetCustomerID(Convert.ToInt16(id));
actionResult = View("Details", cust);
}
else
{
TempData["ErrCode"] = "CustView";
actionResult = RedirectToAction("Index", "Home");
}
}
return actionResult;
}
我有一个视图(其中ActionLink的是)象下面这样:
columns.Template(
@<text>
@Ajax.ActionLink("Detail", "Details", "Customer", new { id = item.CustomerID },
new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "detailCustomer" })
</text>
).Width(70);
渲染输出现在是如下:
<a data-ajax="true" data-ajax-mode="replace" data-ajax-update="#detailCustomer" href="/Customer/Details/2">Detail</a>
如果我点击从浏览器的源代码视图中,我到我的新视图就好了。
但是,如果我尝试点击ActionLink,则视图不会出现。我可以在调试过程中验证,当我点击该控制器代码后,我正在通过详细信息视图。目前的观点只是保持原位而不切换到新的视图。
而且,我可以看到,如果我点击ActionLink的,它执行完全相同的代码(在调试期间),当我将其粘贴到地址栏:
的http://本地主机:4514 /客户//2
当我点击ActionLink的,即使相同的代码被执行详细信息,地址URL不会改变上述情况。和视图不呈现。
我在做什么错?
达林,你是绝对正确的......我完全忘了我发送一个AJAX请求,这将使我保持在同一页面上,而不是重定向。我可以将其更改为您建议的HTML链接,或者在我的网格中执行AJAX回发以保持在同一页面上。对于细节,我会做一个HTML链接,对于编辑,我会保持它的AJAX链接,并让用户执行内联编辑。非常感谢。 – sagesky36