3
votes

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

Error Location

@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

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)

1
Do you have something like "@Url.Content("")" there (Razor)?Ofiris
yes. @Url.Content(ViewBag.UserImageUrl)Ravi Mittal
ViewBag.UserImageUrl is null or empty ?Ofiris

1 Answers

10
votes

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

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