I am trying to display image in view page but it doesn't display in the browser. Here is my code: MyChat.cshtml
<td>
<img src="@Url.Action("GetImage", "Mailbox", new { name = Session["Loginname"].ToString() })" id="photo"/>
</td>
Controller
public FileContentResult GetImage(string name)
{
   byte[] cover = GetImageFromDataBase(name);
   ViewData["image"] = cover;
     if (cover != null)
     {
         return File(cover, "image/jpeg");
     }
     else
     {
           return null;
     }
 }
public byte[] GetImageFromDataBase(string name)
{
   RegisterLogic logic = new RegisterLogic();
   byte[] image = logic.GetImage(name);
   return image;
}
The Business logic i used for retrieving the values from SQL server 2008 R2 is as:
public byte[] GetImage(string name)
        {
            con.ConnectionString = str;
            cmd.Connection = con;
            if (con.State == ConnectionState.Open)
                con.Close();
            if (con.State == ConnectionState.Closed)
                con.Open();
            cmd.CommandText = "Select Picture from InspiniaMessage where UserName='" + name + "'";
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            Message m = new Message();           
            foreach (DataRow dr in dt.Rows)
            {
                Message mn = new Message();
                mn.Picture = (byte[])(dr["Picture"]);
                m.Picture = mn.Picture;             
            }           
            return m.Picture;
            con.Close();
        }
     }
I have not got any error but the image not displays in the view.