有谁知道我们如何使用来自nuget的EmbeddedResourceVirtualPathProvider包吗?

时间:2022-01-14 01:12:48

I am trying to separate my views, controllers and models in a separate DLL and then load them into my host application. When i Google it i found this EmbeddedResourceVirtualPathProvider or VirtualPathProvider may be the way we can do it but unfortunately not found any working sample application or may be anything else which can fulfill this requirement in a good way please let me know. I am using ASP.Net MVC 5 with razor view engine.

我正在尝试在一个单独的DLL中分离我的视图、控制器和模型,然后将它们加载到我的主机应用程序中。当我谷歌的时候,我发现这个EmbeddedResourceVirtualPathProvider或者VirtualPathProvider可能是我们可以实现它的方式,但是不幸的是没有找到任何工作样例应用程序,或者其他任何可以以好的方式满足这个需求的东西,请让我知道。我用ASP。Net MVC 5和razor视图引擎。

Thanks in advance.

提前谢谢。

1 个解决方案

#1


2  

It's better if you try it yourself and then ask questions about problems that you run into. * isn't very good at handing out full solutions; we tend to help with specific problems.

如果你自己尝试一下,然后问一些你遇到的问题,那就更好了。*不擅长提供完整的解决方案;我们倾向于帮助解决特定的问题。

Is the EmbeddedResourceVirtualPathProvider quick-start guide enough to help you?

EmbeddedResourceVirtualPathProvider快速启动指南是否足以帮助您?

A custom VirtualPathProvider for IIS - load views and assets from Embedded Resources in referenced assemblies . To get started, install into your ASP.NET web application via nuget:

一个用于IIS的自定义的虚拟路径提供者,它可以从被引用的程序集的嵌入资源中加载视图和资产。要开始,请安装到您的ASP中。NET web应用程序,通过nuget:

Install-Package EmbeddedResourceVirtualPathProvider

安装包EmbeddedResourceVirtualPathProvider

This will add some code into App_Start registering the provider.

这将向App_Start注册提供程序添加一些代码。

Move views and assets into other assemblies, maintaining folder structure. e.g.

将视图和资产移动到其他程序集中,维护文件夹结构。如。

/MyAspNetApp/Views/Thing/Thing.cshtml -> /ThingComponent/Views/Thing/Thing.cshtml

/ MyAspNetApp /视图/事/。cshtml - > / ThingComponent /视图/事/ Thing.cshtml

And set the the files BuildAction as EmbbeddedResource. Make sure your assembly is referenced, and you're done!

并将文件BuildAction设置为EmbbeddedResource。确保您的程序集被引用,这样就完成了!

By default, all assemblies in the appdomain are scanned. You can restrict this in App_Start\RegisterVirtualPathProvider.cs file. You can also map assemblies to their location on disk, so they [can be] refereshed when you edit the files during development.

默认情况下,将扫描appdomain中的所有程序集。您可以在App_Start\RegisterVirtualPathProvider中对此进行限制。cs文件。您还可以将程序集映射到它们在磁盘上的位置,以便在开发期间编辑文件时引用它们。

#1


2  

It's better if you try it yourself and then ask questions about problems that you run into. * isn't very good at handing out full solutions; we tend to help with specific problems.

如果你自己尝试一下,然后问一些你遇到的问题,那就更好了。*不擅长提供完整的解决方案;我们倾向于帮助解决特定的问题。

Is the EmbeddedResourceVirtualPathProvider quick-start guide enough to help you?

EmbeddedResourceVirtualPathProvider快速启动指南是否足以帮助您?

A custom VirtualPathProvider for IIS - load views and assets from Embedded Resources in referenced assemblies . To get started, install into your ASP.NET web application via nuget:

一个用于IIS的自定义的虚拟路径提供者,它可以从被引用的程序集的嵌入资源中加载视图和资产。要开始,请安装到您的ASP中。NET web应用程序,通过nuget:

Install-Package EmbeddedResourceVirtualPathProvider

安装包EmbeddedResourceVirtualPathProvider

This will add some code into App_Start registering the provider.

这将向App_Start注册提供程序添加一些代码。

Move views and assets into other assemblies, maintaining folder structure. e.g.

将视图和资产移动到其他程序集中,维护文件夹结构。如。

/MyAspNetApp/Views/Thing/Thing.cshtml -> /ThingComponent/Views/Thing/Thing.cshtml

/ MyAspNetApp /视图/事/。cshtml - > / ThingComponent /视图/事/ Thing.cshtml

And set the the files BuildAction as EmbbeddedResource. Make sure your assembly is referenced, and you're done!

并将文件BuildAction设置为EmbbeddedResource。确保您的程序集被引用,这样就完成了!

By default, all assemblies in the appdomain are scanned. You can restrict this in App_Start\RegisterVirtualPathProvider.cs file. You can also map assemblies to their location on disk, so they [can be] refereshed when you edit the files during development.

默认情况下,将扫描appdomain中的所有程序集。您可以在App_Start\RegisterVirtualPathProvider中对此进行限制。cs文件。您还可以将程序集映射到它们在磁盘上的位置,以便在开发期间编辑文件时引用它们。