これは、画像を表示している宛先ページのデザインです
<img alt="" src="@Url.Action("GetPhoto", "Display")" height="50" width="50" class="photo" />
これは私のソースページで、次のようにバインドlinkbutton
します
@Html.ActionLink("QuestionTitle", "Index", "Display", new { QuestionID = item.QuestionID }, null)
ブラウザで上記のURLをクリックすると、目的地は次のようになります。
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
このページを除いて、クエリ文字列を取得できるすべてのページで取得する方法を教えてもらえますか。