HttpRequest.InputStream RRS feed

  • Question

  • Hello, 

    I'm trying to use some code from a .NET project in <g class="gr_ gr_82 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="82" id="82">my .</g>NET Core project. In the code the is a Request.InputStream that Visual Studio says: "HttpRequest does not contain a definition for 'InputStream'". How can I solve this?

    The code is the following: 

    public ActionResult Capture()
                var stream = Request.InputStream;
                string dump;

                using (var reader = new StreamReader(stream))
                    dump = reader.ReadToEnd();

                    DateTime nm = DateTime.Now;

                    string date = nm.ToString("yyyymmddMMss");

                    var path = "~/WebImages/" + date + "test.jpg";

                    System.IO.File.WriteAllBytes(path, String_To_Bytes2(dump));

                    ViewData["path"] = date + "test.jpg";

                    val = date + "test.jpg";

                return View("Index");

            private byte[] String_To_Bytes2(string strInput)
                int numBytes = (strInput.Length) / 2;

                byte[] bytes = new byte[numBytes];

                for (int x = 0; x < numBytes; ++x)
                    bytes[x] = Convert.ToByte(strInput.Substring(x * 2, 2), 16);

                return bytes;

    Wednesday, May 31, 2017 6:16 AM

All replies

  • Hi Daniel Paiva,

    Do you use WebApi Control, which inherit ApiController.

    In ApiController, Request is System.Net.Http.HttpRequestMessage. In Controller, Request is System.Web.HttpRequestBase.

    In ApiController Request does not have a property named InputStream, If you want to retrieve the content in WebApi. please try the following code.

     var stream = HttpContext.Current.Request.InputStream;

    Best regards,

    Cole Wu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 2, 2017 1:22 AM