本文介绍了如何将动态数据从视图传递到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!


我正在尝试从数据库动态加载图像,为此我使用了


I am trying to load the image dynamically from the database,for that i used like

<img src='@Url.Action("GetImage/${ID}", "Home")'  alt = "${name} image" />
but it not reflecting to the controller,but if i put statically like
<img src='@Url.Action("GetImage/1", "Home")'  alt = "${name} image" />


然后将其发送到控制器并显示图像.

我的控制器代码是:


then it is going to the controller and it is displaying image .

my controller code is:

public ActionResult GetImage(int id)
        {
            var imgquery = (from img in dbContext.Listdetails where img.ID == id
                            select new
                            {
                                Image = img.Image
                            }).FirstOrDefault();
            {
                System.IO.MemoryStream outStream = new System.IO.MemoryStream();
                byte[] Image = imgquery.Image;
                return File(Image, "Image/jpg");
            }
        }


任何建议..


Any suggestions..

推荐答案




然后将其发送到控制器并显示图像.

我的控制器代码是:


then it is going to the controller and it is displaying image .

my controller code is:

public ActionResult GetImage(int id)
        {
            var imgquery = (from img in dbContext.Listdetails where img.ID == id
                            select new
                            {
                                Image = img.Image
                            }).FirstOrDefault();
            {
                System.IO.MemoryStream outStream = new System.IO.MemoryStream();
                byte[] Image = imgquery.Image;
                return File(Image, "Image/jpg");
            }
        }


有什么建议.


Any suggestions..


这篇关于如何将动态数据从视图传递到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:07