将MVC站点部署到IIS导致无法找到默认的共享部分视图 [英] Deploying MVC site to IIS results in it cannot find default shared partial view

查看:216
本文介绍了将MVC站点部署到IIS导致无法找到默认的共享部分视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在本地IIS上完美运行的网站.

I have a site that works perfectly on my local IIS.

我的所有页面均使用默认的共享局部视图,该视图称为预期的_Layout.cshtml.该视图位于我的共享文件夹中.可以在这里看到:

All my pages uses a default shared partial view, which is called the expected _Layout.cshtml. This view is placed in my Shared folder. This can be seen here:

这就像我所期望的那样完美.

This works perfectly, as I would expect.

但是,我现在发布我的网站.然后,我在HomeController之外的某些页面显示了:

However, I now publish my website. Then, some of my pages outside the HomeController, results in a :

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Search/Index.aspx
~/Views/Search/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Search/Index.cshtml
~/Views/Search/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

这当然是正确的,但是我希望它在我的共享文件夹中搜索_Layout.cshtml,而不是这些文件名.

This is of course true, but I would expect it to search for _Layout.cshtml in my shared folder, and not these file names.

我该怎么解决?为什么它不能在我的本地IIS上运行,而不能在生产环境上运行?

What can I do to solve it? And why does it work on my local IIS, and not on production?

推荐答案

事实证明,问题完全出在其他地方.

It turns out there problem was somewhere else entirely.

事实证明,许多旧的视图都将内置动作"设置为无".这导致我的视​​图不存在,然后根本找不到它们.

It turned out many of the old views had set "Built action" to "None". That resulted in my views not existing, and then it simply could not find them.

该错误是有道理的,但我没有看到这是实际的问题!

The error makes sense, but I had not seen that this was the actual problem!

这篇关于将MVC站点部署到IIS导致无法找到默认的共享部分视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆