- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的 Web 项目中使用 Aspnetboilerplate 框架。
一切正常,直到我注意到我的生产环境在访问第一页时速度非常慢。
做一些研究后我发现问题是在构建时没有预编译 cshtml View 。因此,在我的 vsts 构建定义中,我添加了以下内容:
/p:PrecompileBeforePublish=true /p:UseMerge=true /p:SingleAssemblyName=AppCode
但现在我的所有 cshtml View 都出现以下错误:
Seduca.Web\obj\Release\AspnetCompileMerge\Source\App\Main\views\aulas\index.cshtml(5,0): Error CS0103: The name 'IsGranted' does not exist in the current context
如果我把它放在每个 View 的顶部就可以工作:
@inherits Seduca.Web.Views.SeducaWebViewPageBase
但看起来我的文件 (web.config) 被忽略了。
我的 .csproj 看起来像这样:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MvcBuildViews>true</MvcBuildViews>
<LangVersion>6</LangVersion>
</PropertyGroup>
...
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<ItemGroup>
<ExtraWebConfigs Include="$(BaseIntermediateOutputPath)\**\web.config" />
<ExtraPackageTmp Include="$([System.IO.Directory]::GetDirectories("$(BaseIntermediateOutputPath)", "PackageTmp", System.IO.SearchOption.AllDirectories))" />
</ItemGroup>
<Delete Files="@(ExtraWebConfigs)" />
<RemoveDir Directories="@(ExtraPackageTmp)" />
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
该错误仅发生在 vsts 构建中。在本地部署中,(使用发布选项和预编译)它可以工作。
我尝试过在 vsts 上使用托管代理和私有(private)代理。
最佳答案
问题似乎是您没有将 namespace 添加到正确的 Web.config
文件中。 .cshtml
文件从 Views\Web.config
文件而不是根 Web.config
文件获取全局导入的命名空间。
根 Web.config
文件中的信息是正确的,只需将其移动到 Views\Web.config
文件即可。
关于asp.net-mvc - cshtml 无法在生产中构建 (vsts),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48208661/
我第一次同时处理 ASP.NET、MVC 3、Web 开发。请耐心听我说,因为我知道这个主题已经从不同角度进行了大量讨论。我仍然没有找到我的具体问题的答案:为什么我的应用程序在出现 404 错误时找不
_PageStart.cshtml 与 _AppStart.cshtml 有什么区别?我可以互换使用它们吗? 最佳答案 _AppStart.cshtml 在应用程序第一次启动时执行一次。它是设置全局变
我有一个 DateTime 和 Date 的编辑器模板。 Date 的内容是 DateTime 的简单复制和粘贴。这是糟糕的复制粘贴编码。 对于用[DataType(DataType.Date)]修饰
当我在 IIS 8 中调用 .cshtml 页面时出现以下错误 “/”应用程序中的服务器错误。不提供此类页面。说明:您所请求的页面类型未被提供,因为它已被明确禁止。扩展名“.cshtml”可能不正确。
当我在 IIS 8 中调用 .cshtml 页面时出现以下错误 “/”应用程序中的服务器错误。不提供此类页面。说明:您所请求的页面类型未被提供,因为它已被明确禁止。扩展名“.cshtml”可能不正确。
每次我单击以创建 View 或部分文件时,Visual Studio 都会自动创建一个 _Layout.cshtml 和一个 _ViewStart.cshtml 文件。 我不希望我的项目创建 _Vie
我知道您可以对带有 url 的普通页面使用布局过滤器,但在出现错误时 View 会发生变化,同时保持 url 不变,因此我无法使用基于路径的新布局。任何帮助,将不胜感激。谢谢! 最佳答案 在我的脑海中
我无法在 mvc 3 razor 的 cshtml 文件中使用 RoleEnvironment.CurrentRoleInstance.Id。 RoleEnvironment 的错误表明它在当前上下文
我知道如果那是条蛇它会咬我的。但我不明白为什么它在 _Layout 头文件中有效,但在我需要它的特定索引页面中却无效。我看不到在每个使用 _Layout.cshtml 的页面中都有此代码。 这是 IF
我有一个分为多个区域的 ASP.NET MVC 4 站点。每个区域都有一个Views/Shared/_Layout.cshtml引用公共(public)共享布局的 View 。在通用布局中,我有一个侧
问题 其实有两个相关的问题: 我应该为每个页面创建一个 ViewModel 吗? 如果您在为两个页面(Create.cshtml 和 Edit.cshtml)创建单个 ViewModel 类时没有问题
在 ASP.Net 5 项目中,默认情况下我有一个名为 _ValidationScriptsPartial.cshtml 的文件:
这里有人可以帮助我吗?我有以下代码: @inherits umbraco.MacroEngines.DynamicNodeContext @{ var node = @Model.NodeBy
我希望有两个_Host.cshtml。我的想法是,我有一个具有非常不同的必需 css 和 js 的登录页面,以及一个具有不同必需的 css 和 js 的主/仪表板页面,我不想在单个 _Host 中加载
我尝试在我的 cshtml 页面中添加一个条件标签 var isTrendClicked = false; function trendChart() { $('.sparkline1'
我有一个简单的选择列表项,被插入下拉列表中。 这是 HTML 结果 Options Option1 Option2 基本上我有这个简单的 JavaScript 脚本 $(document).read
按照 MVC 中的教程,你能告诉我在 ASPX 页面中的替代方法吗 在 cshtml 页面中,VS2013 上 MVC 4 中的默认 View 类型。当我尝试上述时,显示的是字面意思。即
我想知道是否有人测试了他们基于 MVC .NET 的 Web 服务的图形用户界面部分。我用过 Watin/Specflow。我对此有两个主要顾虑: 这些测试不仅仅是图形用户界面。它们是系统检查。他们测
我正在为工作更新 Intranet 站点,需要知道如何水平对齐列表项。我知道这是通过 CSS 完成的,但我在弄清楚使它保持水平的错误所在时遇到了一些问题。 _SiteLayout.cshtml
如果特定列包含重复条目,如何清除 HTML 表格的记录?例如,如果我的表中有 2 列 - 姓名和年龄,如果 2 个人具有相同的年龄,则完全删除第二行。 function DeleteDuplicat
我是一名优秀的程序员,十分优秀!