【发布时间】:2019-04-11 14:02:57
【问题描述】:
每个人。
我构建了一个非常简单的 ASP.NET MVC 应用程序。它工作正常。在 Visual Studio 中从 IIS Express 运行时,一切正常。
我已在 IIS (Windows 10) 上发布,当我尝试访问应用程序时,我在开发工具控制台中出现错误:
GET http://localhost/Content/css/?v=TkaWEc0q1mz3K1xFKH7PU3OH3FTpfcRL8g5pn-9SziE1 net::ERR_ABORTED 403 (Forbidden)
我检查了我的网络选项卡,发现有两个对 Content/css 的调用,这是它们的标题:
我一直在对这个问题进行一些研究,并找到了一些解决方案。到目前为止:
我的 IIS 配置了静态内容 IIS 中 CSS 的 MIME 类型是 text/css,即使标头中的 Content-Type 是 text/html(我不明白为什么)
编辑:根据 cmets 的要求,这是我的配置包:
using System.Web;
using System.Web.Optimization;
namespace IoTHub
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/javascript").Include(
"~/Scripts/bootstrap.min.js",
"~/Scripts/jquery-3.3.1.min.js",
"~/Scripts/popper.min.js",
"~/Scripts/iothub.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/css/bootstrap.min.css",
"~/Content/css/main.css",
"~/Content/css/common.css"));
}
}
}
【问题讨论】:
-
你能发布代码行配置包吗?
-
已编辑,@HienNguyen
标签: c# asp.net asp.net-mvc iis