asp.net-mvc – 值不能为空或为空.参数名称:contentPath
发布时间:2021-01-11 19:36:00 所属栏目:asp.Net 来源:互联网
导读:我在ASP.NET MVC 4中有一个多级布局母版页. 我有以下几点: title@ViewBag.Title/title 布局页面的顺序如下: _Layout.cshtml _SubLayout.cshtml(基于_Layout.cshtml) Index.cshtml(基于_SubLayout.cshtml) 我在Index Action中设置了@ ViewBag.Titl
我在ASP.NET MVC 4中有一个多级布局母版页. 我有以下几点: <title>@ViewBag.Title</title> 布局页面的顺序如下: > _Layout.cshtml 我在Index Action中设置了@ ViewBag.Title.但是,我得到以下异常:
这是我的代码我只是让ASP.NET设计模式图书的代码适用于VS 2012 / MVC 4 _Layout.cshtml <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>@ViewBag.Title</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="header"> <span><a href="@Url.Content("")"> <img alt="Agatha's Clothing Store" src="@Url.Content("/Content/Images/Structure/lg_logo.png")" border="0" /></a></span> </div> <div id="headerSummary"> @RenderSection("headerBasketSummary",required: false) </div> <div class="topBarContainer"> <div id="background"> <div id="navigation"> @RenderSection("MenuContent",required: false) </div> <div id="content"> @RenderBody() </div> <div style="clear: both;" /> </div> </div> @Html.Partial("_SiteFooter") </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.js"></script> <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-jtemplates.js")"></script> <script type="text/javascript" src="@Url.Content("~/Scripts/agatha-common-scripts.js")"></script> </body> </html> _ProductCatalogProduct.cshtml @model BaseProductCatalogPageView @using Agathas.Storefront.Controllers.ViewModels.ProductCatalog @using Agathas.Storefront.UI.Web.MVC.Helpers @{ Layout = "~/Views/Shared/_Layout.cshtml"; } @if (IsSectionDefined("MenuContent")) { @RenderSection("MenuContent",required: false) } else { @Html.Partial("_Categories",((BaseProductCatalogPageView)Model).Categories) } @RenderBody(); Index.cshtml @model HomePageView @using Agathas.Storefront.Controllers.ViewModels.ProductCatalog @using Agathas.Storefront.Services.ViewModels @using Agathas.Storefront.UI.Web.MVC.Helpers @{ Layout = "~/Views/Shared/_ProductCatalogLayout.cshtml"; ViewBag.Title = "Home Page"; } <img width="559" height="297" src="@Url.Content("~/Content/Images/Products/product-lifestyle.jpg")" style="border-width: 0px; padding: 0px; margin: 0px" /> <div style="clear: both;"></div> <h2>Top Products</h2> <div id="items" style="border-width: 1px; padding: 0px; margin: 0px"> <ul class="items-list"> @foreach (ProductSummaryView product in Model.Products) { <li class="item-detail"> <a class="item-productimage-link" href="@Url.Action("Detail","Product",new { id = product.Id },null)"> <img class="item-productimage" src="@Url.Content("~/Content/Images/Products/" + product.Id.ToString() +".jpg"))" /></a> <div class="item-productname">@Html.ActionLink(product.BrandName + " " + product.Name,"Detail",null)</div> <div class="item-price">@product.Price</div> </li> } </ul> </div> 非常感谢 解决方法这段代码抛出异常:< a href =“@ Url.Content(”“)”> ;.这是因为Url.Content方法的contentPath参数不能为空或为空.(编辑:台州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 当注入服务或控制器的依赖关系太多时,重构策
- asp.net – MVC 4导出到CSV – 另存为对话框在Chrome和Fire
- asp.net-mvc – Umbraco 7自定义cookie
- asp.net-mvc – asp.net MVC antiorgerytoken异常RedirectT
- asp.net – 在SQL Server中将日期转换为刻度
- asp.net 汉字转换拼音及首字母实现代码
- global-variables – MVC 3 Razor _ViewStart中的公共变量
- asp.net-mvc – 已经使用相同的参数类型定义了一个名为“Cr
- ASP.NET 程序中删除文件夹导致session失效问题的解决办法分
- ASP.NET对大文件上传的解决方案
推荐文章
站长推荐
- asp.net中使用repeater和PageDataSource搭配实现
- asp.net-mvc – 有没有办法重命名RequestVerific
- asp.net-mvc – 如何检查是否为浏览器启用了cook
- 在ASP.Net网站上使用WCF服务的教程?
- asp.net-mvc – Asp .Net Core – 无法安装Micro
- asp.net – 如何序列化LINQ-to-SQL惰性列表
- asp.net-mvc – ELMAH和SQL Server 2008 R2?
- asp.net-mvc – 通过Gitignore递归地包含Nuget D
- asp.net – 如何从复选框列表中获取最新的选定值
- asp.net-mvc – 如何阻止用户在MVC3应用程序上登
热点阅读