gpt4 book ai didi

asp.net-mvc - Controller 找不到 View

转载 作者:行者123 更新时间:2023-12-02 15:24:11 26 4
gpt4 key购买 nike

我创建了一个项目,其中有一个基本的 DemoController:

<Export(GetType(IController))> _
<ExportMetadata("controllerName", "Demo")> _
<PartCreationPolicy(CreationPolicy.NonShared)> _
Public Class DemoController Inherits Controller

Public Function Index() As ActionResult
Return View("~/Views/Demo/Index.aspx")
End Function

End Class

在我的具有此 Controller 的“插件”项目中,它的路径为/View/Demo/Index.aspx。当我运行我的主网络应用程序时,我可以到达 return View 行,但随后它说找不到该文件。

为什么会这样?

我希望这一切都有意义,并对格式不佳表示歉意。

我可能应该提到我的 .aspx 文件位于另一个项目中,而不是 Web 应用程序中。我将所有内容构建到 dll 中,然后将其放入我的 Web 应用程序项目中的文件夹中。我收到的错误是“未找到 View ‘~/Views/Demo/Index.aspx’或其主视图,或者没有 View 引擎支持搜索的位置。搜索了以下位置:~/Views/Demo/Index.aspx ”

最佳答案

您说您将所有 View 嵌入到一个单独的项目中。使用内置 View 引擎将不起作用。您必须按照此 thread 中指定的方式指定内置 View 引擎中的 View 位置。或创建一个 custom view engine .

关于asp.net-mvc - Controller 找不到 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11021546/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com