视图在 ASP.NET MVC 3 中无法正确呈现
我已将视图从文件夹移至共享文件夹。当我尝试从控制器导航到共享视图时,它导航到默认视图而不是共享视图。我检查了 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保旧视图已删除,否则它将始终选择该视图而不是共享文件夹。
Make sure the old view is deleted, otherwise it will always pick that one over the shared folder.
如果您没有显式定义视图的名称,例如,假设您在
Home
控制器中有一个 ActionResult,视图的名称为
Index.aspx
和/或首先在 Views 文件夹中的
,如果在那里找到匹配的 veiw,则不会进一步搜索。如果未找到,则会在Home
文件夹中搜索 Index.ascxShared
文件夹中搜索它,确保您已从默认位置删除视图
if you have not explicitly defined the name of the view e.g lets suppose you have an ActionResult in
Home
controllerthe view by the name of
Index.aspx
and/orIndex.ascx
is searched first in theHome
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 theShared
foldermake sure you have deleted the view form the Default location