为什么IIS返回空响应? [英] Why does IIS return empty responses?

查看:704
本文介绍了为什么IIS返回空响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用文件系统发布向本地IIS应用程序发布了一个AngularJS / WebAPI项目,我可以在浏览器中打开该网站。不幸的是,不能加载诸如图像,css等资源。当我尝试访问位于子文件夹中的任何文件时,我仍然从服务器收到HTTP 200,但正文是空的。我记得几年前我曾遇到过这个问题,但我不记得为什么会这样。

I just published an AngularJS/WebAPI project using File system publish to a local IIS Application and I can open the website in my browser. Unfortunately, no resources such as images, css etc. can be loaded. When I try to reach any file located in a sub folder I still receive a HTTP 200 from the server, but the body is empty. I can remember I´ve had this issue a few years back but I can´t remember why this happens.

请求

GET http://localhost/Content/images/common/logotype.png HTTP/1.1
Host: XX.XXX.XX.XXX
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,sv;q=0.6

回复

HTTP/1.1 200 OK
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 25 Aug 2015 07:56:12 GMT
Content-Length: 0

如您所见,除了图像中存在图像之外,根本没有正文,我可以从文件系统中打开它。我猜想如果这是一个特权问题,服务器会返回403或类似的错误,而不是200 OK?

As you can see, there is no body at all but the image exists in the folder and I can open it from the filesystem. I would guess that if this was a privilege issue the server would return 403 or a similar error, not 200 OK?

推荐答案

Facepalm

事实证明Lex Li的评论让我朝着正确的方向前进。我完全错过了IIS常见HTTP功能中缺少的静态内容功能。

Turns out that Lex Li:s comment put me in the right direction. I had completely missed to include the "Static Content" feature was missing in IIS "Common HTTP Features".

这篇关于为什么IIS返回空响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆