繁体   English   中英

在ASP.NET Web表单中最小化和捆绑CSS时出现“ 403-禁止访问:拒绝”错误

[英]“403 - Forbidden: Access is denied” error while minification and bundling of CSS in ASP.NET Web Forms

最近,我使用AWS Elastic Beanstalk将ASP.NET Web窗体应用程序从托管VPS转移到了AWS EC2。 当我在托管VPS中使用我的Web应用程序时,捆绑和最小化工作正常。 但是,在转移到Amazon服务器之后,javascript便被成功打包并缩小,但CSS却没有。 当我在浏览器的“查看源代码”中打开缩小的CSS文件时,它显示以下页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>403 - Forbidden: Access is denied.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>403 - Forbidden: Access is denied.</h2>
  <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
 </fieldset></div>
</div>
</body>
</html>

为什么会这样呢?

最终,在对Google进行了一些研究之后,我弄清楚了实际出了什么问题。 http://forums.asp.net/post/5012037.aspx此处提供的解决方案的帮助下,我知道捆绑软件的虚拟路径必须与Web应用程序文件夹中的任何物理路径都不匹配。 因此,我像这样调用bundle <webopt:BundleReference runat="server" Path="~/Content/css" />并且我的Web应用程序的物理根路径还在Content文件夹中包含一个css子文件夹。 因此,我将捆绑软件重命名为styles ,然后像<webopt:BundleReference runat="server" Path="~/Content/styles" /> 现在,它工作正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM