[英]How to return view from another project in ASP NET Core?
I have a simple controller method for testing purpose like this:我有一个简单的 controller 方法用于测试目的,如下所示:
[HttpGet]
public IActionResult Test()
{
return View("SomeView");
}
Assume that I want to create a NuGet package that returns view with name SomeView
, but this view can be implemented by user of my NuGet package. How can I do this?假设我想创建一个 NuGet package 返回名为
SomeView
的视图,但是这个视图可以由我的 NuGet package 的用户实现。我该怎么做? Is this possible?这可能吗?
You are really asking two separate questions here.你真的在这里问两个不同的问题。 One is about accessing views that aren't in the same project as the controller, and a second question about creating a Nuget package.
一个是关于访问与 controller 不在同一个项目中的视图,第二个问题是关于创建 Nuget package。
Have a read of this SO answer to see how to access views in another project.阅读此 SO 答案以了解如何访问另一个项目中的视图。
Once you are comfortable with that, then you can turn that other project into a Nuget package. There are loads of articles around explaining how to do that.一旦您对此感到满意,您就可以将其他项目变成 Nuget package。有很多文章解释了如何做到这一点。 If you have a specific problem doing that, start a new question here.
如果您在这样做时遇到具体问题,请在此处开始一个新问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.