.net - MultipartFormDataStreamProvider vs HttpContext.Current -


i struggling understand why want use multipartformdatastreamprovider when can information using httpcontext.current.

it easier this:

var mydata = httpcontext.current.request.form["mydata"]; 

than this:

string root = httpcontext.current.server.mappath("~/somedir"); var provider = new multipartformdatastreamprovider(root);  this.request.content.readasmultipartasync(provider).continuewith(t => {     var mydata = provider.contents.first(c => c.headers.contentdisposition.name == "\"mydata\"").readasstringasync().result; }); 

ps - trying build apicontroller accept file uploads. i've read article http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2.

this found on msdn. think might you.

the stream provider looks @ content-disposition header field , determines output stream based on presence of filename parameter. if filename parameter present in content-disposition header field body part written filestream, otherwise written memorystream. makes convenient process mime multipart html form data combination of form data , file content.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -