什么mime类型应该作为WOFF字体?
我服务truetype(ttf)字体as font/truetype和opentype(otf)as font/opentype,但我找不到WOFF字体的正确格式.
我曾尝试font/woff,font/webopen和font/webopentype,但Chrome仍然会抱怨:
"资源被解释为字体,但使用MIME类型application/octet-stream进行传输."
有人知道吗?
我需要为IIS Express添加.woff文件扩展名的新MIME映射.
如果我将以下代码段添加到IIS Express的"applicationhost.config",它可以正常工作:
<staticContent lockAttributes="isDocFooterFileName">
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
...
Run Code Online (Sandbox Code Playgroud)
但我真的想把它添加到我的"web.config"中,这样每个开发人员都不需要在本地更改他们的"applicationhost.config".
所以我再次从"applicationhost.config"文件中删除它,并将以下代码段添加到项目的"web.config"中:
<system.webServer>
...
<staticContent>
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
</staticContent>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
不幸的是它似乎没有那样工作,因为当我尝试访问.woff文件时,我最终得到HTTP 404.3错误.
我究竟做错了什么?
这是PUT我的Web API上方法的调用- 方法的第三行(我从ASP.NET MVC前端调用Web API):

client.BaseAddress是http://localhost/CallCOPAPI/.
这是contactUri:

这是contactUri.PathAndQuery:

最后,这是我的405回复:

这是我的Web API项目中的WebApi.config:
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApiGet",
routeTemplate: "api/{controller}/{action}/{regionId}",
defaults: new { action = "Get" },
constraints: new { httpMethod = new HttpMethodConstraint("GET") });
var json = config.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
config.Formatters.Remove(config.Formatters.XmlFormatter);
Run Code Online (Sandbox Code Playgroud)
我试着剥离下来获取传递到路径PutAsJsonAsync,以string.Format("/api/department/{0}", department.Id)和string.Format("http://localhost/CallCOPAPI/api/department/{0}", department.Id)没有运气.
有没有人有任何想法为什么我得到405错误?
UPDATE
根据请求,这是我的部门控制器代码(我将发布我的前端项目的部门控制器代码,以及WebAPI的部门ApiController代码):
前端部门控制员 …
我很感激任何帮助,因为该网站应该今晚上线!
我有一个带有Delete方法的web api控制器.该方法在运行IIS Express(Windows 8)的本地计算机上执行正常,但只要我将其部署到实时IIS服务器(Windows Server 2008 R2),它就会停止工作并抛出以下错误消息:
HTTP错误405.0 - 不允许的方法由于使用了无效的方法(HTTP Verb),无法显示您要查找的页面
我在网上寻找解决方案,并实施了最合理的解决方案.我的网络配置包含以下设置:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
我也试图在IIS中更改处理程序映射和请求筛选无济于事.请注意,IIS中的WebDAV创作规则似乎已被禁用.
任何想法将不胜感激谢谢.
我使用WebClienttype将*.cab文件上传到我的服务器.在服务器端,我使用PUT方法为*.cab文件注册了一个HTTP处理程序,如下所示:
<add name="ResultHandler" path="*.cab" verb="PUT" type="FileUploadApplication.ResultHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode" />
Run Code Online (Sandbox Code Playgroud)
但我总是得到"405方法不允许"的错误.回复称允许的方法如下:
Headers = {Allow: GET, HEAD, OPTIONS, TRACE
Content-Length: 1293
Content-Type: text/html
Date: Fri, 27 May 2011 02:08:18 GMT
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET}
Run Code Online (Sandbox Code Playgroud)
即使我在我的Web应用程序的IIS请求筛选中明确允许PUT方法,仍然会发生相同的错误.
我怀疑这是一个与IIS相关的问题.我希望有人能为我揭开这一点.
---注意:转到EDITED 2部分进行总结----
我有一个ASP.NT MVC(4)应用程序.我集成了(twitter)Bootstrap.Bootstrap工作正常,但是当我发布应用程序时,图标无法正确显示.
我试图重新发布应用程序但没有成功.
为了澄清我在下面放了一些图片.
当我从VS2013运行我的应用程序时,结果就是这样(这没关系):

在展台,IE和Chrome.
但是当我运行已发布的应用程序时,结果是这样的(这不是正常的):


不知何故,这个问题与评估的CSS有关,但我不知道这可能发生在哪一点.
本地应用程序中评估的css是这样的(可以):


但在已发布的应用程序中我有这个(这不是正常的):


有些人经历过这种行为吗?
我能做些什么来解决这个奇怪的问题?
--------------------------- EDITED ---------------------- --------
我得到(字体文件.eot,.svg,.ttf和.woff)要发布我的应用程序时包括在内.当我访问默认页面(应用程序根目录http://localhost/)时,这是显示图标的页面,Chrome的"开发者工具网络"选项卡中显示的文件是:

在包含文件之前,我收到文件的404错误,所以我猜他们会继续被请求,即使它们没有显示在网络选项卡中.
但是,图标显示不正确.
------------------------ EDITED 2 ------------------------ ---
好吧,我在IIS 7中重新启动我的站点.请求开始被触发.这些是Chrome开发者工具网络标签中显示的文件请求:

然后resquest正在寻找文件:/Content/themes/fonts/但它们在:/Content/themes/base/fonts/
该base文件夹包含一个包含bootstrap文件的bootstrap.css文件夹.在CSS文件中有这个类参考字体文件:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}
Run Code Online (Sandbox Code Playgroud)
似乎对字体文件的引用很好,因为文件树是这样的:

我可以将课程改为:
@font-face {
font-family: 'Glyphicons Halflings';
src: …Run Code Online (Sandbox Code Playgroud) 我一直在关注如何设置我的网站以允许跨站点脚本请求的Mozilla文章.使用IIS管理器我添加了以下HTTP响应标头
Access-Control-Allow-Origin : *
Access-Control-Allow-Headers : Origin, SecurityPrivateKeyID
Access-Control-Allow-Methods : GET, POST, PUT, DELETE, OPTIONS
Run Code Online (Sandbox Code Playgroud)
尽管如此,我仍然405 Method Not Allowed在浏览器(Firefox和Chrome)发送带有自定义SecurityPrivateKeyID标头的飞行前请求时.
请求
OPTIONS /Service/Json/User.svc/ HTTP/1.1
Host: serviceprovider.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Origin: http://client.com
Access-Control-Request-Method: GET
Access-Control-Request-Headers: securityprivatekeyid
Connection: keep-alive
Run Code Online (Sandbox Code Playgroud)
响应
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Length: 1565
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/8.0
access-control-allow-origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS …Run Code Online (Sandbox Code Playgroud) 我正在编写WCF服务,这些服务将被客户端使用,因此他们需要处理跨源请求.我在启用开发服务器接受此类请求时遇到问题.这是场景:
当我在IE中运行客户端项目没有问题,因为IE不发送预检OPTIONS请求.当我在Chrome中运行它时,预检OPTIONS请求返回405方法不允许,Chrome放弃了该服务.以前版本的Chrome只会忽略错误并继续执行实际的POST请求(或Get,无论......),但后来的版本似乎更挑剔.
我还使用已部署的WCF项目遇到了这个问题,并通过将OPTIONSVerbHandler移动到IIS中Handler Mappings列表的顶部来解决它.
我应该指出,我正在使用我能想到的最慷慨的web.config设置来尝试允许CORS.例如,我在WCF项目的配置中有这个:
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="*" />
<add name="Access-Control-Allow-Methods" value="*" />
<add name="X-Powered-By" value="*" />
</customHeaders>
</httpProtocol>
Run Code Online (Sandbox Code Playgroud)
无论如何,对代码运行的WCF项目的任何客户端跨源请求都会因405错误而失败.
是否有任何帮助设置WCF项目本身或IIS Express 8以启用CORS?
谢谢!
我正在尝试从AngularJS页面连接到ASP.NET Web-API Web服务,我得到以下内容
凭据标志为"true",但"Access-Control-Allow-Credentials"标头为"".允许凭据必须为"true".原产地" 的http://本地主机:221 "因此不允许访问.
var cors = new EnableCorsAttribute("http://localhost:221", "*","GET,PUT,POST,DELETE");
config.EnableCors(cors);
Run Code Online (Sandbox Code Playgroud)
使用此AngularJS
$http({
method: 'GET',
url: 'http://localhost:1980/api/investors/62632',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
withCredentials: true
// withCredentials: true,
}).then(function onUserComplete(response) {
// this callback will be called asynchronously
// when the response is available
}, function onError(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
Run Code Online (Sandbox Code Playgroud)
阅读了很多文章后,我将其添加到web.config中
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://localhost:221" />
</customHeaders>
</httpProtocol>
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息
'Access-Control-Allow-Origin'标头包含多个值localhost:221,localhost:221,但只允许一个.原因localhost:221因此不允许访问.
这真的没有任何意义,因为我已经添加了一次,它没有找到它,但我将它添加到web.config并得到一个错误说它被添加了多次.我看了很多文章,似乎找不到合适的答案.我正在使用Google Chrome.非常感谢你的帮助,因为我现在正在拔头发.
我正在努力让CORS为我们的SOAP Web服务的新版本(在HTTPS下运行并具有用户名/密码认证)工作,这可以通过JS连接.
目前我在本地(不是跨域)正常工作,但很快它使用不同的域我从WCF Traceviewer得到以下内容.(IIS7中400错误请求)
<ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.</ExceptionString>
Run Code Online (Sandbox Code Playgroud)
它似乎甚至没有到达我的消息检查器运行的部分来添加适当的CORS头.
有没有人经历过这个或者设法让CORS在HTTPS SOAP服务下工作?
我很感激你能给出的任何建议.
干杯,杰米
asp.net-mvc ×3
cors ×3
asp.net ×2
c# ×2
cross-domain ×2
iis-express ×2
wcf ×2
angularjs ×1
css ×1
iis ×1
iis-7 ×1
iis-8 ×1
javascript ×1
json ×1
less ×1
mime-types ×1
soap ×1
woff ×1