【问题标题】:Request.InputStream in ASP.NET CoreASP.NET Core 中的 Request.InputStream
【发布时间】:2018-02-26 19:33:39
【问题描述】:

我正在尝试使用 ASP.NET Core 中的这个库:https://github.com/infusion/jQuery-webcam 来获取从网络摄像头拍摄的照片。

在这个例子中,MVC Capture webcam image, save file path of image to the database,会发生这样的事情:

$(document).ready(function () {
                        $("#Camera").webcam({
                            width: 320,
                            height: 240,
                            mode: "save",
                            swffile: "@Url.Content("~/Scripts/jscam.swf")",
                            onTick: function () { },
                            onSave: function () {
                            },
                            onCapture: function () {
                                webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @Model.Id , pid = @Model.PersonId})");
                            },
                            debug: function () { },
                            onLoad: function () { }
                        });
                   });

从视图中调用了名为Capture 的控制器方法:webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @Model.Id , pid = @Model.PersonId})");

public ActionResult Capture(string ID)
    {
        var path = Server.MapPath("~/Images/ID_" + ID + ".jpg" );

        //var path1 = "~/Images/test.jpg;";



        var stream = Request.InputStream;
        string dump;

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


        if (System.IO.File.Exists(path))
        {
            System.IO.File.Delete(path);
            System.IO.File.WriteAllBytes(path, String_To_Bytes2(dump));
        }
        else System.IO.File.WriteAllBytes(path, String_To_Bytes2(dump));


        return View(ID);

    }

在里面,有一个var stream = Request.InputStream;

问题是在 ASP.NET Core 中没有Request.InputStream

我可以用什么代替?

【问题讨论】:

    标签: c# asp.net asp.net-core


    【解决方案1】:

    Request.Body 是您要查找的流。

    【讨论】:

      【解决方案2】:

      您应该使用“Request.Body”而不是 InputStream

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-03-22
        • 2012-06-21
        • 2015-01-11
        • 1970-01-01
        • 2015-07-11
        • 1970-01-01
        • 2016-10-21
        相关资源
        最近更新 更多