- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Asp.Net MVC 4 项目中,我在 .csproj 文件中设置了构建 View <MvcBuildViews>true</MvcBuildViews>
.问题是构建项目时出现错误:It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
我试图删除 obj 文件夹,但错误不断增加。错误指出问题出在身份验证标记行中:
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
最佳答案
执行@matrixugly 建议的操作将解决该问题,但也会导致编译时 View 检查也停止工作。我假设您仍然想在编译时错误检查您的 View ?如果是这种情况,请在下面进行更好的修复。
为了理解这些解决方案为何有效,我们必须首先了解问题是如何产生的:
MvcBuildViews=true
. It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
<project-dir>\obj\
放置它将使用的源文件的副本。不幸的是,这些文件在发布完成后不会自动删除。下次开发者用
MvcBuildViews=true
编译项目时,会报错,因为aspnet编译器包含
obj\
编译期间的文件夹,因为它在
<project-dir>
下文件夹。
MvcBuildViews=false
.我真的不认为这是一个解决方案,所以让我们继续。 <project-dir>\obj\
中的文件.有效,但可能会很麻烦,因为它必须在每次发布后完成。 <BaseIntermediateOutputPath>
更改发布用作中间目录的路径项目配置文件中的属性。示例(引用:this link):<BaseIntermediateOutputPath>
[SomeKnownLocationIHaveAccessTo]
</BaseIntermediateOutputPath>
<PropertyGroup>
<_EnableCleanOnBuildForMvcViews Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='' ">true</_EnableCleanOnBuildForMvcViews>
</PropertyGroup>
<Target Name="CleanupForBuildMvcViews" Condition=" '$(_EnableCleanOnBuildForMvcViews)'=='true' and '$(MVCBuildViews)'=='true' " BeforeTargets="MvcBuildViews">
<ItemGroup>
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\Package\**\*" />
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\TransformWebConfig\**\*" />
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\CSAutoParameterize\**\*" />
<_TempWebConfigToDelete Include="$(BaseIntermediateOutputPath)**\TempPE\**\*" />
</ItemGroup>
<Delete Files="@(_TempWebConfigToDelete)"/>
</Target>
Unload Project
来卸载它。 .然后,您可以右键单击该项目并编辑该项目文件。或者,您可以在 Visual Studio 之外编辑文件。
关于asp.net-mvc - allowDefinition ='MachineToApplication' 错误设置 <MvcBuildViews>true</MvcBuildViews>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12778088/
我在创建新文件夹并向其中上传文件时遇到此错误。我有一个已构建的现有站点,但我不想将其添加到该站点,而是让它本身就是一个应用程序。有任何想法吗? 最佳答案 这确实是第一个要检查的场景。但是,发生此错误的
在根目录下,我具有以下结构 .. .. .. web.config Report Folder - Login.aspx - Web.config | |-> ViewReport
在我们的开发环境中运行的 Intranet 应用程序上出现此错误,我不确定该去哪里/寻找解决方案。该应用程序过去运行良好,但它与另一个开发人员团队在共享服务器上运行,我们无法跟踪错误(我的团队没有对应
添加到 web.config 后,从 VS 2013/2012 发布 MVC 项目失败 或 等(部分注册为 allowDefinition='MachineToApplication')。 患者:
我已经下载了 ASP.Net 的在线项目。运行应用程序时出现错误 It is an error to use a section registered as allowDefinition='Mach
关于这个主题有大量的 SO 帖子。到目前为止,解决方案似乎是将 IIS 中的目录配置为应用程序。另一个常见的解决方案是从根目录中的文件夹中删除备份的 web.config 文件。 我的问题有所不同,因
是否可以使用 appcmd 更改 allowDefinition 的值?具体来说,我尝试在应用程序级别启用对 httpCompression 模块的更改。 通过手动更改以下行来修改 applicati
在我的 Asp.Net MVC 4 项目中,我在 .csproj 文件中设置了构建 View true .问题是构建项目时出现错误: It is an error to use a section r
我在 SO 上看到了一些关于在部署网站时出现类似错误的问题,但我似乎在 时随机收到此错误。建筑 Visual Studio 中的 ASP.NET MVC 网站。执行清洁通常可以修复它,但是有什么方法可
我是一名优秀的程序员,十分优秀!