code_junkie

Mvc Release Candidate “File” ActionResult

Nov 14th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. var a = Helper.Service.GetAttachmentById(id, MembershipProvider.SecurityTicket);
  2.  
  3. if (a == null)
  4. {
  5. return View(new ImagePlaceHolderViewData(new { Id = id }));
  6. }
  7. return View(new ImagePlaceHolderViewData(new { Id = a.Id, Image = a, FileContent = File(a.Data, a.ContentType) }));
  8.  
  9. <img src="<%=Model.FileContent.FileContents %>" />
  10.  
  11. <img src="<%=Model.FileContent%>" />
  12.  
  13. <img src="<%=Model.FileContent.FileContents %>" />
  14.  
  15. <img src="/image/result/12345" />
  16.  
  17. public class ImageController : Controller
  18. {
  19. public ActionResult Result(int resultID)
  20. {
  21. // Do stuff here...
  22.  
  23. return File(..);
  24. }
  25. }
  26.  
  27. <img src="FileStream#1" />
  28.  
  29. <img src="/Images/View/1" />
  30.  
  31. <img src="data:image/gif;base64,<%=Convert.ToBase64(Model.FileContent)%>"/>
Add Comment
Please, Sign In to add comment