diff --git a/README.md b/README.md index eb211d4..b634dc0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ The RequireJS for .NET project smoothly integrates the RequireJS framework with ### Documentation +* [Setup RequireJS for ASP.NET MVC using NuGet](http://www.stefanprodan.eu/2013/08/setup-requirejs-for-asp-net-mvc-using-nuget/) * [Setup and configuration](https://github.com/stefanprodan/RequireJSDotNet/wiki/RequireJS-for-.NET-setup) * [Programming guide](https://github.com/stefanprodan/RequireJSDotNet/wiki/Programming-with-RequireJS-for-.NET) diff --git a/RequireJsNet/RequireJsHtmlHelpers.cs b/RequireJsNet/RequireJsHtmlHelpers.cs index a55ad42..843721b 100644 --- a/RequireJsNet/RequireJsHtmlHelpers.cs +++ b/RequireJsNet/RequireJsHtmlHelpers.cs @@ -69,11 +69,16 @@ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html) : "Root"; var controller = html.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue as string; var action = html.ViewContext.Controller.ValueProvider.GetValue("action").RawValue as string; - - var entryPoint = "Controllers/" + area + "/" + controller + "/" + controller + "-" + action; + var entryPointTmpl = "Controllers/{0}/" + controller + "/" + controller + "-" + action; + var entryPoint = string.Format(entryPointTmpl, area); var filePath = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js"); - - return File.Exists(filePath) ? new MvcHtmlString(entryPoint) : null; + if (File.Exists(filePath)) + { + return new MvcHtmlString(entryPoint); + } + entryPoint = string.Format(entryPointTmpl, "Common"); + var fallbackFile = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js"); + return File.Exists(fallbackFile) ? new MvcHtmlString(entryPoint) : null; } public static MvcHtmlString GetRequireJsPaths(this HtmlHelper html, string configPath = "")