gpt4 book ai didi

asp.net - ASP MVC 5 - View 文件夹外部的部分 View 文件

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

我有一个部分 View 文件,它接收保存在 View 目录之外的@model - 实际上存储在app_data中。

但是我收到错误:

The name 'model' does not exist in the current context
Source File: ...\app_data\_DefaultLayout.cshtml

下面是我的代码:

 @Html.Partial("~/app_data/_DefaultLayout.cshtml"), Model)

默认布局如下:

 @using System.Web.Mvc
@using System.Web.Mvc.Html
@model MyApp.ViewModels.CreateCaseViewModel

// some html and razor code

最佳答案

此异常是 cshtml 文件上的编译错误。该 View 无法访问模型类型。如果您检查解决方案资源管理器,会发现有两个 web.config 文件,一个位于 Views 文件夹中,另一个位于根级别。

排序的一种方法是将 Views/web.config 复制到 App_Data 中。

关于asp.net - ASP MVC 5 - View 文件夹外部的部分 View 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46989618/

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