视图在 ASP.NET MVC 3 中无法正确呈现

发布于 2024-12-07 07:48:40 字数 136 浏览 2 评论 0原文

我已将视图从文件夹移至共享文件夹。当我尝试从控制器导航到共享视图时,它导航到默认视图而不是共享视图。我检查了 Global.asax,在 Global.asax 中创建了新路由,但它仍然指向默认路由并加载默认视图。

有人能帮我解决这个问题吗?

I have moved a view from folder to Shared folder. When I try to navigate from controller to the shared view it is navigating to the default view and not the shared view. I checked in Global.asax, I created new route in the Global.asax, but it is still pointing to the default route and loading the default view.

Could anyone help me in resolving this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听不够的曲调 2024-12-14 07:48:40

确保旧视图已删除,否则它将始终选择该视图而不是共享文件夹。

Make sure the old view is deleted, otherwise it will always pick that one over the shared folder.

安稳善良 2024-12-14 07:48:40

如果您没有显式定义视图的名称,例如,假设您在 Home 控制器中有一个 ActionResult,

public ActionResult Index()
{
return View();
}

视图的名称为 Index.aspx 和/或 首先在 Views 文件夹中的 Home 文件夹中搜索 Index.ascx,如果在那里找到匹配的 veiw,则不会进一步搜索。如果未找到,则会在 Shared 文件夹中搜索它,

确保您已从默认位置删除视图

if you have not explicitly defined the name of the view e.g lets suppose you have an ActionResult in Home controller

public ActionResult Index()
{
return View();
}

the view by the name of Index.aspx and/or Index.ascx is searched first in the Home folder which is present in the Views folder if a matching veiw is found there it is not searched further. If it is not found then it will be searched in the Shared folder

make sure you have deleted the view form the Default location

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文