便携式地区没有发现嵌入文件MVC4 C# [英] Portable Area not finding embedded files MVC4 C#
问题描述
我有在这两个项目的解决方案。便携式领域的项目,网站引用便携领域的项目,这两个参考MvcContrib。
I have a solution with two projects in it. A portable areas project, and a web site that references the portable areas project, and Both reference MvcContrib.
我的问题有与嵌入的资源,他们给了我一个404错误,当我试图让他们。好像它试图访问一个物理路径而不是DLL。局部视图正常工作。
The problem I am have is with the embedded resources, they are giving me a 404 error when I try to get to them. It seems like it's trying to access a physical path not the dll. The partial view works fine.
我试图访问的文件看起来像这样我的Visual Studio解决方案资源管理器内
The file I'm trying to access looks like this inside my visual studio solution explorer
AdHocReporting /地区/ AdHocReportBuilder /内容/ adhoc.css(生成操作嵌入)
AdHocReporting/Areas/AdHocReportBuilder/Content/adhoc.css (the build action is embedded)
下面是便携领域的路由:
using System.Web.Mvc;
using MvcContrib.PortableAreas;
namespace AdHocReporting.Areas.AdHocReportBuilder
{
public class AdHocReportBuilderAreaRegistration : PortableAreaRegistration
{
public override string AreaName
{
get { return "AdHocReportBuilder"; }
}
public override void RegisterArea(AreaRegistrationContext context, IApplicationBus bus)
{
RegisterRoutes(context);
RegisterAreaEmbeddedResources();
}
private void RegisterRoutes(AreaRegistrationContext context)
{
context.MapRoute(
AreaName + "_content",
base.AreaRoutePrefix + "/Content/{resourceName}",
new { controller = "EmbeddedResource", action = "Index", resourcePath = "Content" },
new[] { "MvcContrib.PortableAreas" }
);
context.MapRoute(
AreaName + "_default",
base.AreaRoutePrefix + "/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
}
这里是具有参考便携式领域的网站Global.aspx
namespace AdHocReportingSite
{
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
PortableAreaRegistration.RegisterEmbeddedViewEngine();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
}
这里是什么我的解决方案,开发类似的外观图片:
推荐答案
无法重现该问题,一旦我创建了一个新的项目,重做一切。我不知道这是否是一个错误或我只是错过设立我的便携式领域的一个步骤。
Could not reproduce the issue once I created a new project and redid everything. I'm not sure if it was an error or I just missed a step in setting up my portable areas.
这篇关于便携式地区没有发现嵌入文件MVC4 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!