【问题标题】:Configuring Virtual Directory for Multiproject Areas in MVC3在 MVC3 中为多项目区域配置虚拟目录
【发布时间】:2012-06-04 13:04:15
【问题描述】:

我正在使用此答案中描述的技术:https://stackoverflow.com/a/7167198/22399 在 MVC3 中设置多项目区域。不过,我的问题似乎在于配置 IIS Express,而不是技术本身。

我在第 7 步中做错了(使用 IIS Express。)我不断收到错误消息,说它找不到视图(我的测试区域称为“示例”)这是错误:

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:

~/Areas/Sample/Views/Index/Index.aspx<br />
~/Areas/Sample/Views/Index/Index.ascx<br />
~/Areas/Sample/Views/Shared/Index.aspx<br />
~/Areas/Sample/Views/Shared/Index.ascx<br />
~/Views/Index/Index.aspx<br />
~/Views/Index/Index.ascx<br />
~/Views/Shared/Index.aspx<br />
~/Views/Shared/Index.ascx<br />
~/Areas/Sample/Views/Index/Index.cshtml<br />
~/Areas/Sample/Views/Index/Index.vbhtml<br />
~/Areas/Sample/Views/Shared/Index.cshtml<br />
~/Areas/Sample/Views/Shared/Index.vbhtml<br />
~/Views/Index/Index.cshtml<br />
~/Views/Index/Index.vbhtml<br />
~/Views/Shared/Index.cshtml<br />
~/Views/Shared/Index.vbhtml

我的 IIS Express applicationhost.config 是这样设置的:

    <site name="Vo.MainSite" id="5">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="D:\{LONG PATH}\MainSite\MainSite\MainSite" />
        </application>
        <application path="/Areas/Sample" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="D:\{LONG PATH}\Modules\SampleModule\SampleModule.Web" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation="*:47001:localhost" />
        </bindings>
    </site>

从我搜索的所有内容来看,它应该是正确的。我有复制 DLL 的后期构建过程就好了。我可以在 SampleController 中放置一个断点,然后断点就会被命中。一切看起来都很好,除了找到风景。有什么建议吗?

【问题讨论】:

  • 所以,我现在几乎放弃了在单独的项目中拥有视图的想法。将控制器放在单独的项目中既好又容易,所以我会坚持下去。但我暂时不考虑这个问题。希望有一天,有人会想出一种流畅、简单、可维护且受工具支持的方式来完成此任务。
  • 在类似的情况下,我通过添加具有读取权限的 IIS_IUSRS 来编辑虚拟目录的权限。开始发现视图。
  • 你试过Almas的建议了吗?它对我有用。我有一些不同的设置 - vb.net webforms 项目作为主项目,从内部引用 razor mvc3 c# 项目,并将 Views 作为虚拟文件夹。添加上面提到的权限(我最初放了IUSR)解决了这个问题

标签: asp.net-mvc-3 iis-express


【解决方案1】:

确保您的视图被标记为嵌入式资源。

【讨论】:

  • 似乎没有什么不同。
猜你喜欢
  • 2019-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多