GVKun编程网logo

asp.net – 带有transfer-enconding的POST:在IIS 8.5 Web API中chunked失败(.net发送post请求)

13

如果您对asp.net–带有transfer-enconding的POST:在IIS8.5WebAPI中chunked失败感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于as

如果您对asp.net – 带有transfer-enconding的POST:在IIS 8.5 Web API中chunked失败感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于asp.net – 带有transfer-enconding的POST:在IIS 8.5 Web API中chunked失败的详细内容,我们还将为您解答.net发送post请求的相关问题,并且为您提供关于Accept-Encoding: gzip, deflate ; Transfer-Encoding: chunked ; Content-Encoding: gzip、android API的Linkedin API getConnectionsfor currentuser()异常、asp.net – context.Response.Charset = Encoding.UTF8.ToString();、asp.net – Transfer-Encoding:Chunked cause 404系统找不到指定的文件的有价值信息。

本文目录一览:

asp.net – 带有transfer-enconding的POST:在IIS 8.5 Web API中chunked失败(.net发送post请求)

asp.net – 带有transfer-enconding的POST:在IIS 8.5 Web API中chunked失败(.net发送post请求)

我在IIS 8.5上运行ASP.NET Web API,我的POST方法接受json文档的主体.现在,客户端应用程序正在使用apache httpclient,它显然会自动将transfer-encoding:chunked标头添加到请求中.我的API方法因为不存在的主体而引发异常 – 它不能反序列化正文中的json,即使它在客户端日志中看起来很好.

我应该如何处理确保获得全身的请求?我想IIS也应该支持请求的传输编码,因为它是HTTP / 1.1规范的一部分,对吧?

有一个类似的问题没有答案:Reading Body on chunked transfer encoded http requests in ASP.NET

解决方法

您必须基本上检查ContentLength标头并将其设置为null(如果它为0).

public class ChunkJsonMediaTypeFormatter : JsonMediaTypeFormatter
{
    public override Task<object> ReadFromStreamAsync(Type type,Stream readStream,HttpContent content,IFormatterLogger formatterLogger)
    {
        content.Headers.ContentLength = (content.Headers.ContentLength == 0) ? null : content.Headers.ContentLength;

        return base.ReadFromStreamAsync(type,readStream,content,formatterLogger);
    }
}

连接这个格式化程序

GlobalConfiguration.Configure(config =>
{
    var jsonFormatter = new ChunkJsonMediaTypeFormatter() { SerializerSettings = config.Formatters.JsonFormatter.SerializerSettings };
    config.Formatters.Remove(config.Formatters.JsonFormatter);
    config.Formatters.Insert(0,jsonFormatter);
}

https://gist.github.com/jayoungers/0b39b66c49bf974ba73d83943c4b218b

Accept-Encoding: gzip, deflate ; Transfer-Encoding: chunked ; Content-Encoding: gzip

Accept-Encoding: gzip, deflate ; Transfer-Encoding: chunked ; Content-Encoding: gzip

 

POST /APP_upgrade/HttpServer HTTP/1.1
Host: app-upgrade.rongyu360.com:8083
Content-Type: application/json
Connection: keep-alive
Accept: */*
User-Agent: shou ji kan ke tang/1.0 (iPhone; iOS 10.3.1; Scale/3.00)
Accept-Language: zh-Hans-CN;q=1, en-CN;q=0.9
Content-Length: 217
Accept-Encoding: gzip, deflate

POST /APP_upgrade/HttpServer HTTP/1.1
Host: app-upgrade.rongyu360.com:8083
Content-Type: application/json
Connection: keep-alive
Accept: */*
User-Agent: shou ji kan ke tang/1.0 (iPhone; iOS 10.3.1; Scale/3.00)
Accept-Language: zh-Hans-CN;q=1, en-CN;q=0.9
Content-Length: 217
Accept-Encoding: gzip, deflate

{"MsgHead":{"version":"1.0","direction":"request","msgType":"MSG_VERSION_UPGRADE"},"MsgBody":{"appId":"32010020170410210656735050w045fr","userLan":"zh-Hans-CN","cuType":"iOS","cuVersion":"1","systemVersion":"10.3.1"}}HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Authentication-Info: Digest realm=realm@host.com,nextnonce=8jjupbrv86wl4i5qoo85gypx0dn5r520ww
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Mon, 17 Apr 2017 08:47:30 GMT

a
..........
aa
L..
.0...{..e......P.n^..A.j......Va..|I./.$...../0..V...wv...*dz''
i.=...5.y@.."..(/.YZ..q.......H>.H&....G.u.....[.}Zwvg2.M...H..~......Gd..0G...>.UW.7......1.=`]O_.....
a
....C.....
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Authentication-Info: Digest realm=realm@host.com,nextnonce=8jjupbrv86wl4i5qoo85gypx0dn5r520ww
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Mon, 17 Apr 2017 08:47:30 GMT

a
..........
aa
L..
.0...{..e......P.n^..A.j......Va..|I./.$...../0..V...wv...*dz''
i.=...5.y@.."..(/.YZ..q.......H>.H&....G.u.....[.}Zwvg2.M...H..~......Gd..0G...>.UW.7......1.=`]O_.....
a
....C.....
0

 

android API的Linkedin API getConnectionsfor currentuser()异常

android API的Linkedin API getConnectionsfor currentuser()异常

我正在为Androidlinkedin-j-android.jar使用linkedin API.

通过此操作,我可以从我的Android应用程序和client.getProfileForCurrentUser();登录到我的帐户.和client.updateCurrentStatus(“状态已从android应用更新”);也可以.

我面临的问题是,每当我打电话给
client.getConnectionsForCurrentUser();要么
连接connections = client.getConnectionsForCurrentUser(connectionFields); ,我得到异常“对连接的访问​​被拒绝”.如何提供权限或有其他解决方法?我被困在这里.帮我解决这个问题

提前致谢

解决方法:

我已经将此API用于linkedIn.它可以帮助我发布状态并获得联系.

http://code.google.com/p/socialauth-android/

asp.net – context.Response.Charset = Encoding.UTF8.ToString();

asp.net – context.Response.Charset = Encoding.UTF8.ToString();

我在我的代码中使用了这个来设置Charset,但IE不喜欢它.有什么理由吗?

context.Response.Charset = Encoding.UTF8.ToString();

我最终必须将它设置为context.Response.ContentType =“application / json; charset = utf-8”或context.Response.Charset =“utf-8”;代替.不知道那是什么Encoding.UTF8.ToString();如果IE无法接受它将被用于

解决方法

Context.Response.Charset = Encoding.UTF8.WebName;

获取为Internet Assigned Numbers Authority(IANA)注册的当前编码名称.

asp.net – Transfer-Encoding:Chunked cause 404系统找不到指定的文件

asp.net – Transfer-Encoding:Chunked cause 404系统找不到指定的文件

我试图发布到IIS6提供的页面,我正在添加以下标题:

transfer-encoding: chunked

当我这样做时,我收到404错误:系统找不到指定的文件..如果我向没有此标题的页面发出相同的请求,它肯定存在.

这是标题 – 两个请求之间的唯一区别是分块…

POST http://hostname/appname/index.html HTTP/1.1
Host: hostname
Connection: keep-alive
transfer-encoding: chunked
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML,like Gecko) Chrome/26.0.1410.64 Safari/537.31
Content-Type: application/x-www-form-urlencoded
Referer: http://referrer/

和身体:

4
xxxx
0

IIS元数据库在W3SVC级别将AspEnableChunkedEncoding设置为true,并且不会在站点级别覆盖它.

为什么我会收到404错误?

更新:我注意到对不成功请求的响应:

x-powered-by: asp.net

…标题缺席.我不知道这是否有帮助 – 如果我没有在请求中设置标题,它就在那里.

解决方法

是否安装了URLScan?它可能会阻止标题

关于asp.net – 带有transfer-enconding的POST:在IIS 8.5 Web API中chunked失败.net发送post请求的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Accept-Encoding: gzip, deflate ; Transfer-Encoding: chunked ; Content-Encoding: gzip、android API的Linkedin API getConnectionsfor currentuser()异常、asp.net – context.Response.Charset = Encoding.UTF8.ToString();、asp.net – Transfer-Encoding:Chunked cause 404系统找不到指定的文件等相关知识的信息别忘了在本站进行查找喔。

本文标签: