值不能为null或为空.参数名称:contentPath [英] Value cannot be null or empty. Parameter name: contentPath

查看:997
本文介绍了值不能为null或为空.参数名称:contentPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MVC应用程序面临一个奇怪的问题,一切正常,我现在不知道此应用程序发生了什么.我只是更新所有的nuget包. 出现以下错误

I am facing a strange issue with my MVC application, everything works fine i don't know what happened to this app now. I just update all the nuget packages. Getting the below error

Value cannot be null or empty. Parameter name: contentPath at

错误位置

@System.Web.Optimization.Scripts.Render("~/bundles/modernizr") @System.Web.Optimization.Scripts.Render("~/bundles/jquery")

@System.Web.Optimization.Scripts.Render("~/bundles/modernizr") @System.Web.Optimization.Scripts.Render("~/bundles/jquery")

我没有对捆绑包配置进行任何更改,并且我具有所有必需的脚本. 这是完整的堆栈跟踪

i did not change anything to bundles configuration and i have all the required scripts. here is that complete stack trace

异常:System.ArgumentException:值不能为null或为空. 参数名称:contentPath位于 System.Web.Mvc.UrlHelper.GenerateContentUrl(String contentPath, HttpContextBase(httpContext)在 System.Web.Mvc.UrlHelper.Content(String contentPath)位于 System.Dynamic.UpdateDelegates.UpdateAndExecute2 [T0,T1,TRet](CallSite 站点,T0 arg0,T1 arg1)在 f:\ Sample中的ASP._Page_Views_Shared__AdminLayout_cshtml.Execute() Projects \ Notebook \ Notebook \ Views \ Shared_AdminLayout.cshtml:第23行位于 System.Web.WebPages.WebPageBase.ExecutePageHierarchy()在 System.Web.Mvc.WebViewPage.ExecutePageHierarchy()在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,TextWriter编写器,WebPageRenderingBase startPage)位于 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,TextWriter作家)在 System.Web.WebPages.WebPageBase.<> c_ DisplayClass7.b _6(TextWriter writer),位于System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) 在System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult内容),网址为 System.Web.WebPages.WebPageBase.Write(HelperResult结果)位于 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName,动作1 body) at System.Web.WebPages.WebPageBase.PopContext() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 过滤器,Int32 filterIndex,ResultExecutingContext preContext, ControllerContext controllerContext,ActionResult actionResult)位于 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 过滤器,Int32 filterIndex,ResultExecutingContext preContext, ControllerContext controllerContext,ActionResult actionResult)位于 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList 1过滤器,ActionResult actionResult)位于 System.Web.Mvc.Async.AsyncControllerActionInvoker.<> c_ DisplayClass21.<> c _DisplayClass2b.b_ 1c() 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<> c _DisplayClass21.b__1e(IAsyncResult asyncResult)

Exception: System.ArgumentException: Value cannot be null or empty. Parameter name: contentPath at System.Web.Mvc.UrlHelper.GenerateContentUrl(String contentPath, HttpContextBase httpContext) at System.Web.Mvc.UrlHelper.Content(String contentPath) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at ASP._Page_Views_Shared__AdminLayout_cshtml.Execute() in f:\Sample Projects\Notebook\Notebook\Views\Shared_AdminLayout.cshtml:line 23 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) at System.Web.WebPages.WebPageBase.<>c_DisplayClass7.b_6(TextWriter writer) at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) at System.Web.WebPages.WebPageBase.Write(HelperResult result) at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) at System.Web.WebPages.WebPageBase.PopContext() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c_DisplayClass21.<>c_DisplayClass2b.b_1c() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c_DisplayClass21.b__1e(IAsyncResult asyncResult)

推荐答案

您正在使用空/空参数调用@Url.Content(ViewBag.UserImageUrl).

You are calling @Url.Content(ViewBag.UserImageUrl) with a null / empty argument.

在呼叫之前放置一个断点并检查ViewBag.UserImageUrl.

Place a breakpoint before the call and inspect ViewBag.UserImageUrl.

这篇关于值不能为null或为空.参数名称:contentPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆