简体   繁体   English

css在服务器iis 7上运行不正常,就像本地一样

[英]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: 要发布我的应用:

  • I've used button publish ( in VS 2012) 我用过按钮发布(在VS 2012中)
  • Choose file System (publish method) 选择文件系统(发布方法)
  • Browse the application from IIS manager 从IIS管理器中浏览应用程序

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问题。

  1. Check if CSS is the same on both servers (maybe you didn't deploy correct css file). 检查两台服务器上的CSS是否相同(可能是您没有部署正确的css文件)。
  2. Check if it is not a cache issue (clean all browser cache). 检查它是否不是缓存问题(清除所有浏览器缓存)。
  3. Check in another browser. 检查另一个浏览器。

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.

相关问题 Multiview 在 IIS 服务器中不起作用,但在我的本地服务器(XAMPP)中运行良好 - Multiview is not working in IIS server, but working well in my local server (XAMPP) DirectorySearcher 在本地工作但不在 IIS 服务器中工作 - DirectorySearcher working in Local but not working in IIS server WCF服务在本地而非服务器IIS上运行以实现功能 - WCF service working on local not server IIS for functions kendo grid update \\ insert在IIS服务器上不起作用,但在本地服务器上起作用 - kendo grid update\insert not working on IIS server but it is working on Local Ajax自动完成CSS在iis和服务器上工作正常,但在本地计算机上工作不正常 - Ajax Auto complete Css works fine in iis and the server but not in local machine jQuery ajax form.serialize()在服务器和本地IIS上不起作用 - jquery ajax form.serialize() not working on Server and on local IIS 无法通过IIS服务器发送电子邮件(在本地工作) - Not able to send E-mail through IIS server (Working in local ) MVC应用程序在IIS Express中工作正常,但在本地IIS Web服务器中不工作 - MVC Application is working fine in IIS Express but not working in Local IIS web server 防止对IIS服务器的本地访问 - Preventing Local Access to IIS Server OAuth 2.0无法在本地IIS上运行 - OAuth 2.0 not working on Local IIS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM