_VIEwStart.csHTML:@{ Layout = "~/VIEws/Shared/_ProfileLayout.csHTML";}Index.csHTML insIDe my Profile folder: @{VIEwBag.Title = "Index"; }IndexController Action:public ActionResult Index() { //Todo: BusinessLogic //This method gets called twice //******************// return VIEw(); }
这似乎是一个简单的问题,我肯定错过了一些明显的东西.我在这个网站上发布了示例项目: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 src="../../Scripts/jquery-1.8.2.Js" type="text/JavaScript"></script> <script src="../../Scripts/jquery-ui-1.9.1.custom.Js" type="text/JavaScript"></script></head><body><div > <div > <div ID="loginimagecontainer"> @using (HTML.BeginForm("LoginActions","Account",FormMethod.Post,new { @ID = "LoginActionsForm" })) { @HTML.AntiForgeryToken() <a href="#"><img src="/images/icons/message-icon.png" wIDth="60" height="60" alt="Messages" title="Messages"/></a> <a href="/Account/logoff"><img src="/images/icons/log-out-icon.png" wIDth="60" height="60" alt="Log off" title="Log off"/></a> } </div> <div ><img alt="TestMVCProject logo" src="#" wIDth="350" height="150" ID="TestMVCProjectlogo" /></div> </div> <div > <div ID="leftPane"> <img src="#" alt="Placeholder" wIDth="165" height="200" ID="ProfilePhoto" title="Profile Photo" /> <div ID="Username"></div> <div ID="Navlinks"> <div onclick="Navigate('/Profile/Update')"><span>Profile</span><img src="/images/icons/edit-icon.png" wIDth="30" height="30" alt="Profile" /></div> <div ><span>Search</span><img src="/images/icons/search-icon.png" wIDth="30" height="30" alt="Search" /></div> <div onclick="Navigate('/Photo')"><span>Photos</span><img src="/images/icons/camera-icon.png" wIDth="30" height="30" alt="Photos"/></div> </div> </div> <div ID="adcontainer"> <h4>Ads go here</h4> <p>content goes here</p> </div> <div ID="centerPane"> @RenderBody() </div> </div> @RenderPage("~/VIEws/Shared/_Footer.csHTML") <div ID="redirectiondialog" > <br /> hey,wait up... we're redirecting you over to the login page <br /> </div> <script type="text/JavaScript"> function Navigate(url) { window.location = url; return false; } </script></div></body></HTML>
这是页脚页面:
<div > <div >copyright 2012 TestMVCProject Inc </div> <p><a href="/Profile/Test">About</a> | <a href="#">Contact</a> | <a href="#">FAQ</a> | <a href="#">Advertise</a> | <a href="#">Support</a> | <a href="#">Feedback</a> | <a href="#">Login</a> | <a href="#">Register</a> | <a href="#">Privacy</a> | <a href="#">Terms</a></p> </div>
更新:
@TIEson T:谢谢,我把它改为HTML.Partial而不是RenderPage.但是问题仍然存在,因为 *** 作方法仍然被调用两次…(编辑描述,因为我没有添加注释的权限)
<img alt="TestMVCProject logo" src="#" wIDth="350" height="150" ID="TestMVCProjectlogo" />
src回到了同一页面.一旦我用“”替换它,它现在工作正常.
总结以上是内存溢出为你收集整理的c# – 指定布局时,MVC控制器 *** 作多次调用全部内容,希望文章能够帮你解决c# – 指定布局时,MVC控制器 *** 作多次调用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)