我能够成功登录owamail并获得身份验证cookie。我在owamail上执行了一个搜索请求,我在httpwebresponse上收到400个错误请求。下面是根据浏览器搜索HTTP post请求,即xmlhttprequest。
Request Parameters =<params><canary>value</canary><st><FVLVS few parameters />....etc
请求详细信息:
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://owamail.mysite.net/OWA/ev.owa?Oeh=1&ns=MsgVLV2&ev=LoadFresh&pfmk=M23:11111111")
Request.method= post
Request.keepalive=false
Request.contenttype= "text/plain;charset=UTF-8";
Request.protocolversion= httpversion.version10
Request.allowautoredirect=true
Request.proxy=null
Request.timeout=800000
Request.readwritetimeout=800000
Request.User agent="Mozilla/4.0 (compatible; MSIE 8.0; windows NT 6.0; wow64;" "Trident/4.0; SLCC1; NET CLR 2.0.50727; media center pc 5.0;"
Request.header.add("accept-encoding", "gzip, deflate");
Request.contentlength= data1.length
答案 0 :(得分:0)
首先,将WebRequest强制转换为像这样的HttpWebRequest
HttpWebRequest request= (HttpWebRequest)HttpWebRequest.Create(@"https://owamail.mysite.net/OWA/ev.owa?Oeh=1&ns=MsgVLV2&ev=LoadFresh&pfmk=M23:11111111");
然后,添加以下代码行:(**注意根据操作系统兼容性,Useragent会有所不同)
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox访问此链接以了解Mozilla支持的用户代理字符串引用。