C# ASP.NET MVC 5 - 加载字形图标和 jquery UI 样式时出错 500



我目前正在用C# ASP NET MVC 5编写调度程序。

昨天我在本地 IIS 服务器上部署我的应用程序,我注意到我的字形和我的 jquery ui 的样式不再起作用 (我的网络工具中的错误 500)。

我已经尝试了许多堆栈溢出的解决方案,例如e 上的许多主题

错误使我 我的 jquery 捆绑包

问题是,即使是局部的,字形也不能很好地工作。

这是我已经测试过的不同解决方案:

  • 使用不同的名称加载我的捆绑包以避免名称文件夹的冲突
  • 使用 CssRewriteUrlTransform 创建捆绑包
  • 从引导程序的网站下载字体并手动插入
  • 将 IIS Mime 类型配置为正确加载 .ttf、.woff、.woff2

我会继续我的搜索,欢迎任何帮助

祝大家有美好的一天,

D. =)

[编辑] 我按照您的要求添加 _Layout.cshtml ;)

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Planning</title>
@Styles.Render("~/Content/css") 
@Styles.Render("~/Content/cssjqryUi")
@Styles.Render("~/Content/themes/base/css")
@Styles.Render("~/Content/fullcalendarcss")
@Styles.Render("~/Content/bootstrap")
@Styles.Render("~/Content/bootstrap-theme")
@Styles.Render("~/Content/awesome")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@Html.Action("_Menu", "Layout")
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; @DateTime.Now.Year - Si2A Planning</p>
</footer>
</div>

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap") 
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/fullcalendarjs")
@Scripts.Render("~/bundles/planifier")

[编辑] Web.Config 文件,只有不正确的部分。这是一个不见了的安抚。

<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="ADConnectionString" connectionString="LDAP://xxxxxxx"/>
<add name="PlanningEntities" connectionString="metadata=res://*/Models.PlanningBDD.csdl|res://*/Models.PlanningBDD.ssdl|res://*/Models.PlanningBDD.msl;provider=System.Data.SqlClient;provider connection string=xxxxxxxxxx;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<authentication mode="Forms">
<forms name=".ADAuthCookie" loginUrl="~/Account/Login" timeout="45" slidingExpiration="false" protection="All"/>
</authentication>
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
<add name="AspNetActiveDirectoryMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName"/>
</providers>
</membership>
<compilation debug="true" targetFramework="4.6.2" />
<httpRuntime targetFramework="4.6.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />

我也遇到了这个问题,并通过在 web.config 中为 MIME 类型放置一个条目来设法修复它。

<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
</system.webServer>

希望这对你有用。

)

好的,我已经解决了它。

我的 web.config "损坏"。有一行(仍在查找)有错误。

现在,如果您遇到此错误,请创建一个新的ASP MVC应用程序 ->并将"新"web.config逐节复制到旧应用程序中。

这将修复此编译错误。

我将更新此答案以保留此错误的历史记录以及何时找到问题的真正来源。

最新更新