dotnet core Razor类库的视图找不到

帅动的笑脸
  • 17

开发环境 win10 vs2017
我在一个解决方案里,做了一个Razor类库,做了一下ui。debug模式下生成了 lib.dlllib.views.dll
同一个解决方案中,另一个mvc的网站项目,引用了 此项目,显示没有问题。
另一个解决方案中,一个mvc的网站项目,引用了 lib.dlllib.views.dll,但是显示错误,找不到cshtml

clipboard.png

clipboard.png

clipboard.png

clipboard.png

VCardCoreWeb中的_ViewStart.cshtml
clipboard.png
VCardCoreWeb 运行是没有问题的,可以找到这个_Layout.cshtml

但是在另外一个解决方案的项目中,就显示找不到_Layout.cshtml

clipboard.png

clipboard.png

这个怎么解决??

回复
阅读 1.8k
1 个回答
 public static void AddVCardO2OUI(this IServiceCollection services)
        {
            services.Configure<RazorViewEngineOptions>(
                o =>
                {
                    o.AreaViewLocationFormats.Clear();
                    o.AreaViewLocationFormats.Add("~/Areas/{2}/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/Areas/{2}/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/Areas/{2}/Views/Shared/BasePage/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/Views/Shared/BasePage/{0}" + RazorViewEngine.ViewExtension);

                    o.AreaViewLocationFormats.Add("~/Areas/{2}/O2OViews/{1}/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/Areas/{2}/O2OViews/Shared/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/Areas/{2}/O2OViews/Shared/BasePage/{0}" + RazorViewEngine.ViewExtension);

                    o.AreaViewLocationFormats.Add("~/O2OViews/Shared/{0}" + RazorViewEngine.ViewExtension);
                    o.AreaViewLocationFormats.Add("~/O2OViews/Shared/BasePage/{0}" + RazorViewEngine.ViewExtension);

                    o.ViewLocationFormats.Clear();

                    o.ViewLocationFormats.Add("~/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
                    o.ViewLocationFormats.Add("~/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
                    o.ViewLocationFormats.Add("~/Views/Shared/BasePage/{0}" + RazorViewEngine.ViewExtension);

                    o.ViewLocationFormats.Add("~/O2OViews/{1}/{0}" + RazorViewEngine.ViewExtension);
                    o.ViewLocationFormats.Add("~/O2OViews/Shared/{0}" + RazorViewEngine.ViewExtension);
                    o.ViewLocationFormats.Add("~/O2OViews/Shared/BasePage/{0}" + RazorViewEngine.ViewExtension);
                });
        }

将 O2OView 改成自己的

另外,我用了nuget,直接引用dll,view.dll 不知道会不会出现问题

你知道吗?

宣传栏