这是我显示图像的目标页面设计
<img alt="" src="@Url.Action("GetPhoto", "Display")" height="50" width="50" class="photo" />
这是我的源页面,我将我的绑定linkbutton
如下
@Html.ActionLink("QuestionTitle", "Index", "Display", new { QuestionID = item.QuestionID }, null)
我在浏览器中单击上述网址时的目的地如下
http://localhost:1931/Display?QuestionID=1
这是我试图显示图像的代码
[HttpGet]
public ActionResult GetPhoto()
{
// int quesID = Convert.ToInt16(Request.QueryString["QuestionID"].ToString()); this didn't worked so by having a look at quick watch I write the below
int quesID = Convert.ToInt16(Request.UrlReferrer.Query.Substring(12, 1));
byte[] photo = null;
var usrname = (from a in db.tblQuestions
where a.QuestionID == quesID
select new { a.UserName });
var v = db.tblUsers.Where(p => p.UserName == usrname.FirstOrDefault().UserName).Select(img => img.Photo).FirstOrDefault();
photo = v;
return File(photo, "image/jpeg");
}
有人可以告诉我如何在querystring
除此页面之外的每个页面上获取查询字符串。