核心库中的 MVC
MVC in a Core Library
我构建了这个项目,它包含一个简单的 MVC 类型结构来帮助调试信息。现在公司想在图书馆等其他应用程序中使用它
最好的方法,我可以描述它是
我的项目 Debugger 是一个带有多个端点的控制器,用于呈现视图(非常基本),用 C# 编写。
我想要的是当另一个项目想要包括我的调试时,他们会:
- 使用 NuGet 添加 Debugger 作为参考。
- 然后在 Start.cs 中,开发人员将使用 IApplicationBuilder.UseDebugger(IConfiguration, OtherInformation) 或 IServiceCollection.UseDebugger(IConfiguration, OtherInformation) 和 Debugger 扩展会做剩下的事情,比如注册路由,构建依赖注入所需的东西。
我不知道要使用什么项目类型,我使用 .NET Core Web Application 3.1 构建它,但我不认为是那样。我还尝试了 .Net Standard class 库,但我无法获得对控制器的引用以呈现视图。
总而言之,我想将我项目的一部分转换为一个库,以便分发到其他应用程序。
示例项目的 link 也会有所帮助。
听起来你想要一个 Razor Class Library。
Razor views, pages, controllers, page models, Razor components, View components, and data models can be built into a Razor class library (RCL). The RCL can be packaged and reused. Applications can include the RCL and override the views and pages it contains. When a view, partial view, or Razor Page is found in both the web app and the RCL, the Razor markup (.cshtml file) in the web app takes precedence.
编辑:我刚刚意识到我 answered a question 上个月设置了一个 Razor Class 库,所以这也会给你一个起点。
我构建了这个项目,它包含一个简单的 MVC 类型结构来帮助调试信息。现在公司想在图书馆等其他应用程序中使用它 最好的方法,我可以描述它是
我的项目 Debugger 是一个带有多个端点的控制器,用于呈现视图(非常基本),用 C# 编写。
我想要的是当另一个项目想要包括我的调试时,他们会:
- 使用 NuGet 添加 Debugger 作为参考。
- 然后在 Start.cs 中,开发人员将使用 IApplicationBuilder.UseDebugger(IConfiguration, OtherInformation) 或 IServiceCollection.UseDebugger(IConfiguration, OtherInformation) 和 Debugger 扩展会做剩下的事情,比如注册路由,构建依赖注入所需的东西。
我不知道要使用什么项目类型,我使用 .NET Core Web Application 3.1 构建它,但我不认为是那样。我还尝试了 .Net Standard class 库,但我无法获得对控制器的引用以呈现视图。
总而言之,我想将我项目的一部分转换为一个库,以便分发到其他应用程序。
示例项目的 link 也会有所帮助。
听起来你想要一个 Razor Class Library。
Razor views, pages, controllers, page models, Razor components, View components, and data models can be built into a Razor class library (RCL). The RCL can be packaged and reused. Applications can include the RCL and override the views and pages it contains. When a view, partial view, or Razor Page is found in both the web app and the RCL, the Razor markup (.cshtml file) in the web app takes precedence.
编辑:我刚刚意识到我 answered a question 上个月设置了一个 Razor Class 库,所以这也会给你一个起点。