[英]css not working well in server iis 7 like on local
When I debug my ASP MCV 4 Application on Visual Studio 2012, CSS displays properly. 当我在Visual Studio 2012上调试我的ASP MCV 4应用程序时,CSS显示正常。 I deployed it to IIS 7, but I notice that not all the CSS is working as It was in local , some styles are missing.
我将它部署到IIS 7,但我注意到并非所有的CSS都在工作,因为它在本地,有些样式缺失。 I've edited the render string so that It does not resemble to my actual directory structure as it's said here but I didn't get the good result .
我已经编辑了渲染字符串,因此它与我的实际目录结构不一样,因为它在这里说,但我没有得到好结果。 Any idea how to handle this issue ?
知道如何处理这个问题吗?
Update 更新
In order to publish my app: 要发布我的应用:
When clicking on F12 : I got these messages "Failed to load resource: the server responded with a status of 404 (Not Found) " It's about some images that are not found 单击F12时:我收到这些消息“无法加载资源:服务器响应状态为404(未找到)”这是关于一些未找到的图像
And I'm using bundles to include CSS files 我正在使用bundle来包含CSS文件
try 尝试
BundleTable.EnableOptimizations = false;
In bundle config 在捆绑配置中
Just remove the App_Themes
Folder in Request Filtering Feature. 只需删除请求过滤功能中的
App_Themes
文件夹即可。
IIS7 -> Site -> (Ursitename)
, in the right panel it has "Request Filtering"
, IIS7 -> Site -> (Ursitename)
,在右侧面板中有"Request Filtering"
,
open the feature and remove the App_Themes Folder from it. 打开该功能并从中删除App_Themes文件夹。 and refresh and browse.
并刷新和浏览。
It's not an IIS matter. 这不是IIS问题。
IE has developer tools (F12). IE有开发人员工具(F12)。 Check if that header has the same css style in both versions...
检查两个版本中的标头是否具有相同的css样式...
Also Check by giving the correct path , 同时通过给出正确的路径进行检查 ,
Since the problem occurs on CSS only, do you use full path to CSS? 由于问题仅出现在CSS上,您是否使用CSS的完整路径?
<link href="http://pcname/website/file.css" rel="Stylesheet" type="text/css" />
Use this 用这个
<link href="file.css" rel="Stylesheet" type="text/css" />
If not, than it might be also some permissions issue. 如果没有,可能还会有一些权限问题。 Then you locally browsing
http://local
it would use your local account, when browsing http://pcname
you will be recognized as a remote user who might have no rights to access css file or folder. 然后你在本地浏览
http://local
它将使用你的本地帐户,当浏览http://pcname
你将被识别为可能无权访问css文件或文件夹的远程用户。
It might happen that the HTTP request for a bundle is handled by IIS instead of the MVC framework. 可能会发生捆绑的HTTP请求由IIS而不是MVC框架处理。 This kind of routing conflict may happen when the virtual path of the bundle matches a real path on the file system.
当捆绑的虚拟路径与文件系统上的真实路径匹配时,可能发生这种路由冲突。
As stated at the end of the official ASP.NET documentation ( http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification ): 正如ASP.NET官方文档末尾所述( http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification ):
A good convention to follow when creating bundles is to include "bundle" as a prefix in the bundle name.
创建捆绑包时要遵循的一个好习惯是在捆绑包名称中包含“bundle”作为前缀。 This will prevent a possible routing conflict.
这将防止可能的路由冲突。
Therefore, I suggest you rename your bundles making sure that the name is not similar to any path in your website. 因此,我建议您重命名捆绑包,确保该名称与您网站中的任何路径不相似。
You can take a look at the answers to these similar issues: 您可以查看这些类似问题的答案:
我终于找到了解决方案,并在BundleConfig中添加这一行:
BundleTable.EnableOptimizations = false;
我修复了我在webconfig上评论静态文件处理程序的问题
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.