草庐IT

content_parsed

全部标签

c# - HttpRequest.Content.IsMimeMultipartContent() 在应该返回 true 时返回 false

我需要将HTTP请求作为MultiPartFormData发送到RESTController。它正在工作,但现在我对我的Controller进行的检查声称请求的类型不正确,即使我可以在调试器中看到请求的类型正确。供引用:这是调用它的控制台应用程序代码:usingSystem;usingSystem.IO;usingSystem.Net.Http;usingSystem.Net.Http.Headers;usingSystem.Text;namespaceQuickUploadTestHarness{classProgram{staticvoidMain(string[]args){us

c# - Web Api 请求抛出 "Error while copying content to a stream."

我正在尝试实现这个codeexample,但得到一个HttpRequestException-“将内容复制到流时出错。”当调用ReadAsStringAsync()方法时。内部异常是“无法访问已处置的对象”。我正在使用Fiddler来发出请求。我不明白。有人可以解释为什么我会收到此异常并提供解决方案吗?网络API方法:publicasyncTaskPost(HttpRequestMessagerequest){try{varjsonString=awaitrequest.Content.ReadAsStringAsync();}catch(Exceptionex){throw;}ret

c# - 设置 "Always copy to output directory"时,Content 和 None 有什么区别?

在csproj文件中,我们可以使用None或Content元素包含一个文件。来自MSDN,它说:None-Thefileisnotincludedintheprojectoutputgroupandisnotcompiledinthebuildprocess.Anexampleisatextfilethatcontainsdocumentation,suchasaReadmefile.Content-Thefileisnotcompiled,butisincludedintheContentoutputgroup.Forexample,thissettingisthedefaultva

c# - float.Parse 在小数点和逗号上失败

当我尝试这条线时:floatf=float.Parse(val,System.Globalization.NumberStyles.AllowDecimalPoint|System.Globalization.NumberStyles.AllowThousands);其中val是设置为“5.267”且不带引号的字符串,我收到此错误:格式异常:未知字符:。System.Double.Parse(System.Strings、NumberStyles样式、IFormatProvider提供程序)System.Single.Parse(System.Strings,NumberStyles样

c# - 无效的 URI : The Authority/Host could not be parsed from very long url

这是Youtube视频的实际url,此时如果您复制到您的chrome浏览器,您可以观看该视频。但是,当我尝试创建请求时,我得到了UriFormatException。我做错了什么?HttpWebRequestrequest=(HttpWebRequest)HttpWebRequest.Create(url);http:/r6---sn-x5jjxnn-ogul.googlevideo.com/videoplayback?ratebypass=yes&ms=au&fexp=924615,912522,932260,910207,936330,916611,936117,936910,93

c# - 我必须如何更改此 XML 字符串以便 XDocument.Parse 读取它?

在下面的代码中,我将一个对象序列化为一个XML字符串。但是当我尝试使用XDocument.Parse将此XML字符串读入XDocument时,它给了我这个错误:Invaliddataatrootlevel.XML是:1JimJones23434更新:这是十六进制:![alttext][1]Mod编辑-禁用超链接:指向恶意软件的链接我必须对该XML做什么才能使其无错误地读入XDocument?usingSystem;usingSystem.Collections.Generic;usingSystem.Xml.Serialization;usingSystem.IO;usingSyste

c# - long.Parse() C#

我如何在C#中将字符串(例如“-100,100”)转换为long。我目前有一行代码是longxi=long.Parse(x,System.Globalization.NumberStyles.AllowThousands);但是当x是“负数”时,这会中断。我的方法:longxi=long.Parse("-100,253,1",System.Globalization.NumberStyles.AllowLeadingSign&System.Globalization.NumberStyles.AllowThousands);错了,因为它坏了。 最佳答案

c# - DateTime.ParseExact() 比 DateTime.Parse() 快吗

我想知道ParseExact是否比Parse快。我认为它应该是ParseExact,因为您已经提供了格式,但我也认为所有对文化信息的检查都会减慢它的速度。微软是否在任何文件中说明了两者之间的性能差异。要使用的格式是通用的“yyyy/MM/dd”格式。例如:DateTime.Parse(DateText);DateTime.ParseExact(DateText,"yyyy/MM/dd",CultureInfo.InvariantCulture); 最佳答案 您要求两种功能不同(接近但仍然不同)的方法在速度上存在差异。只需选择最合适的

c# - 单声道缺少 System.Numerics.BigInteger.Parse(string,IFormatProvider)

我目前在使用Json.NET/Newtonsoft.JSON时遇到以下错误图书馆:MissingmethodSystem.Numerics.BigInteger::Parse(string,IFormatProvider)inassembly/usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll,referencedinassembly~/dev/Mono/Mercury/Mercury/bin/Debug/Newtonsoft.Json.dll每当从couchDB数据库中检索到的J

c# - 错误 (HttpWebRequest) : Bytes to be written to the stream exceed the Content-Length bytes size specified

我似乎无法弄清楚为什么我不断收到以下错误:BytestobewrittentothestreamexceedtheContent-Lengthbytessizespecified.在以下行:writeStream.Write(bytes,0,bytes.Length);这是一个Windows窗体项目。如果有人知道这里发生了什么,我肯定会欠你一个。privatevoidPost(){HttpWebRequestrequest=null;Uriuri=newUri("xxxxx");request=(HttpWebRequest)WebRequest.Create(uri);request