我遇到一个问题,控制器动作被调用至少两次.我有一个视图,它有另一个视图作为其布局页面,并且视图被多次调用.如果我删除布局的规范,则操作将始终执行一次.我浏览了StackOverflow和其他网站,但找不到与我有相同特征的问题,所以我发布了一个新问题.
_ViewStart.cshtml:
@{
Layout = "~/Views/Shared/_ProfileLayout.cshtml";
}
Index.cshtml inside my Profile folder: @{
ViewBag.Title = "Index";
}
Index
Controller Action:
public ActionResult Index()
{
//ToDo: BusinessLogic
//This method gets called twice
//******************//
return View();
}
Run Code Online (Sandbox Code Playgroud)
这似乎是一个简单的问题,我肯定错过了一些明显的东西.我在这个网站上发布了示例项目:https://skydrive.live.com/#cid = F2DAB940147490B0&id = F2DAB940147490B0%21140
有什么想法有什么不对吗?
谢谢
更新:以下是视图:@ {ViewBag.Title ="TestMVCProject"; Layout = null; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TestMVCProject</title>
<link rel="Stylesheet" type="text/css" href="../../Content/ActiveSite.css" />
<link href="../../Content/themes/TestMVCProject/jquery-ui-1.9.1.custom.min.css" rel="stylesheet" type="text/css" />
<script …Run Code Online (Sandbox Code Playgroud)