写真を表示するページがいくつかあります。コードが[投稿のアート]に示されているコントローラーアクションを呼び出します。問題は、シュレッディングから読み込まれた画像であり、すぐに読み込まれるのではなく、最初にテキストを表示してから画像を表示することです。さらに2つ試しました画像をロードするための正確な方法ですが、同じ効果... 1つずつロードしてください。現在のコードアクションを助けてください
public FileContentResult ImageVew(string sourcePath)
{
string location = (string)Session["TicketFilePath"] + sourcePath;
byte[] myByte = System.IO.File.ReadAllBytes(location);
return File(myByte, "image/jpeg");
Image i;
using (MemoryStream ms = new MemoryStream())
{
ms.Write(myByte, 0, myByte.Length);
i = Image.FromStream(ms);
}
return File(imageToByteArray(i.GetThumbnailImage(100, 100, () => false, IntPtr.Zero)), "image/png");
}
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
return ms.ToArray();
}
このメソッドの最後のバージョンですが、結果はありません
public ActionResult ImageVew(string sourcePath)
{
FileInfo fi = new FileInfo((string)Session["TicketFilePath"] + sourcePath);
return File(fi.FullName, Utilities.MimeType(fi.Name));
}
public ActionResult ImageVew(string sourcePath)
{
FileInfo fi = new FileInfo((string)Session["TicketFilePath"] + sourcePath);
byte[] imageFile = System.IO.File.ReadAllBytes(fi.FullName);
return new FileContentResult(imageFile, Utilities.ImageType(fi.Name));
}
public ActionResult ImageVew(string sourcePath)
{
FileInfo fi = new FileInfo((string)Session["TicketFilePath"] + sourcePath);
if (fi.Exists)
{
byte[] imageFile = System.IO.File.ReadAllBytes(fi.FullName);
return File(imageFile, Utilities.ImageType(fi.Name));
}
else return null;
}
画像を 1 つずつレンダリングし、ネットワーク パスから画像をロードしています...しかし、1. 画像のキャッシングをロードした後、すぐに開発者の皆さんを助けてください
パート f コードは、レンダリング m コントロールでアクションを呼び出します
private void WriteDataRow(Class item, HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.RenderBeginTag(HtmlTextWriterTag.Center);
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "20px");
string src = Url.Action("ImageVew", new { sourcePath = item.Status.Marker });
writer.AddAttribute(HtmlTextWriterAttribute.Src, src );
writer.AddAttribute(HtmlTextWriterAttribute.Alt, item.Status.StatusName);
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}