草庐IT

HttpPostedFile

全部标签

javascript - 如何在 C# 中检索字符串 formData js

我必须在我的.net网络API中检索“idPerson”的值。我已经检索到文件“UploadedImage”。但是我无法检索“idPerson”的值。有人有解决办法吗?谢谢!我的js函数/***Uploaddel'imagedeprofil*@methoduploadFile*@private*/uploadFile:function(){vardata=newFormData(),files,ajaxRequest;files=$("#fileUpload").get(0).files;//Ajoutdel'imageuploadéverslesdonnéesduformif(fil

C# - 我无法引用 HttpPostedFileBase

我在带有CSLA的分布式环境中使用MVC.NET,我可以从我的网络层之一(例如Website.MVC)引用HttpPostedFileBase,但我不能从单独的层(我们称之为OtherLayer.Web)引用HttpPostedFileBase。知道我需要做什么才能调用HttpPostedFileBase吗?我可以在两个层中使用HttpPostedFile-我应该只使用它吗?程序集引用基本相同-在Website.MVC中我有:namespaceWebsite.Mvc.Controllers{usingSystem;usingSystem.Collections;usingSystem.

c# - HttpPostedFileBase 与 HttpPostedFileWrapper 的关系

我了解HttpPostedFileBase和HttpPostedFileWrapper之间的关系,就两者的需求而言(即在单元测试/模拟中)。但是,为什么当我在HttpPostedFileBase的返回值上设置断点时,它是否显示为HttpPostedFileWrapper?此外,HttpPostedFileBase没有实现ContentType属性。那么,当我的代码仅引用HttpPostedFileBase而不是HttpPostedFileWrapper时,为什么它会返回一个值?这是什么诡计?编辑#1:感谢@lawliet29的精彩回复。我已经按照建议写出了结构。publicsealed

c# - 如何实例化 HttpPostedFile

我正在尝试与我无法控制的系统进行通信,但是它的一种方法采用HttpPostedFile在我的代码中我有一个字节数组。有没有人有实例化HttpPostedFile的例子,因为我知道它的构造函数是内部的?我找到的最好的是CreatinganinstanceofHttpPostedFilewithReflection它使用反射,但是它们被引导到另一个我不能接受的方向,因为我无法修改第三方系统方法签名。 最佳答案 这真的是非常hacky代码,但以下似乎对我有用:publicHttpPostedFileConstructHttpPostedF

c# - 如何从 HttpPostedFile 创建字节数组

我正在使用具有FromBinary方法的图像组件。想知道如何将输入流转换为字节数组HttpPostedFilefile=context.Request.Files[0];byte[]buffer=newbyte[file.ContentLength];file.InputStream.Read(buffer,0,file.ContentLength);ImageElementimage=ImageElement.FromBinary(byteArray); 最佳答案 使用BinaryReader对象从流中返回字节数组,如:byte[

c# - 如何从 HttpPostedFile 创建字节数组

我正在使用具有FromBinary方法的图像组件。想知道如何将输入流转换为字节数组HttpPostedFilefile=context.Request.Files[0];byte[]buffer=newbyte[file.ContentLength];file.InputStream.Read(buffer,0,file.ContentLength);ImageElementimage=ImageElement.FromBinary(byteArray); 最佳答案 使用BinaryReader对象从流中返回字节数组,如:byte[

c# - 在 C# 中获取 HttpPostedFile 的字符串内容的最短方法是什么

我有一个HttpPostedFile对象,只需要提取已发布文件的内容。我找到了thislink但仅获取包含内容的字符串是一个非常漫长的过程。有没有更短的方法?(最好是一行指令。) 最佳答案 varstr=newStreamReader(postedFile.InputStream).ReadToEnd();StreamReader.ReadToEnd 关于c#-在C#中获取HttpPostedFile的字符串内容的最短方法是什么,我们在StackOverflow上找到一个类似的问题:

c# - 上传的 HttpPostedFile 为空

在View上:在Controller中,有这样的东西:[AcceptVerbs(HttpVerbs.Post)]publicActionResultAbout(HttpPostedFilepostedFile){//butpostedFileisnullView();}postedFile在About()中为空。如何上传文件? 最佳答案 使用HttpPostedFileBase(不是HttpPostedFile),并按照表单中的名称准确命名参数。例如。如果你有你必须有方法头:publicActionResultAbout(HttpP