TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chaitanya
NA
58
57k
Image binding MVC actionresult razor view
Feb 7 2016 3:51 AM
Hi all I am binding the img tag as follows
<img alt=
""
src=
'@Url.Action("UserImage", "Home")'
class
=
"avatar img-circle img-thumbnail"
/>
This is my code to get the image from the database
[HttpGet]
public
ActionResult UserImage()
{
string
user = Session[
"UserName"
]
as
string
;
byte
[] photo =
null
;
var v = db.table.Where(p => p.USER_NAME == user).Select(img => img.PHOTO).FirstOrDefault();
if
(v !=
null
)
{
photo = v;
return
File(photo,
"image/jpeg"
);
}
else
return
null
;
}
This is displaying image when I have in the database but when it is null it is displaying as follows, instead of that i need to bind src tag with empty
Reply
Answers (
2
)
how can we use abstraction and polymorphism in project
Auto suggest dropdownlist/listbox/etc.-URGENT