Пример #1
0
 public ActionResult ReadContent()
 {
     int bookId = Convert.ToInt32(Request.Url.Segments[3].TrimEnd('/'));
     string file = HttpUtility.UrlDecode(string.Join("", Request.Url.Segments.Skip(4)));
     using (var db = new EbooksContext()) {
         var userId = db.GetEbooksUser(User).UserId;
         var book = db.Books.Single(b => b.BookId == bookId && b.UserId == userId);
         if (book == null) return null;
         using (var ep = new Epub(book)) {
             return new FileStreamResult(ep.GetContentFile(file), "text/html");
         }
     }
 }