Image 如何绑定<;img>;如果我在blob中存储图像,是否使用blob uri标记html以在ui上显示图像?

Image 如何绑定<;img>;如果我在blob中存储图像,是否使用blob uri标记html以在ui上显示图像?,image,asp.net-mvc-4,azure,razor,Image,Asp.net Mvc 4,Azure,Razor,我正在azure blob中存储图像,我想在UI上显示这些图像,但我想用blob uri绑定我的img标记。 我怎样装订一张支票 我正在尝试注释部分,即搜索将uri传递给img标记的方法…但没有得到任何位置。。。因此,请帮助我在控制器和索引中进行哪些更改以获得所需的结果。如果您已将图像保存在blobstorage中,则可以从 public class HomeController : Controller { public ActionResult Index() {

我正在azure blob中存储图像,我想在UI上显示这些图像,但我想用blob uri绑定我的img标记。 我怎样装订一张支票


我正在尝试注释部分,即搜索将uri传递给img标记的方法…但没有得到任何位置。。。因此,请帮助我在控制器和索引中进行哪些更改以获得所需的结果。

如果您已将图像保存在blobstorage中,则可以从

public class HomeController : Controller
{

    public ActionResult Index()
    {
        ViewBag.path = @"F:\download_button_small2.png";
        return View();
    }

    public FileContentResult myAction(string path)
    {        
        string fileName = Path.GetFileNameWithoutExtension(path);
        byte[] imageInBytes = System.IO.File.ReadAllBytes(path);
        //upload image to blob and URL in table
        ImageContainer img = new ImageContainer();
        string imageUri = img.insert(fileName, imageInBytes);
        //returns back the image uri from Blob Storage            
        return new FileContentResult(imageInBytes, "image/png");
    }      
}
http://.blob.core.windows.net//  
修改您的操作方法,以返回一个以该URL作为其值的字符串

另外,请确保您的存储帐户设置为公共访问

有关使用Azure Blob存储的更多详细信息,请参见以下内容:


此图像存储在哪里?您提到了blob存储,但您的代码提到了本地驱动器路径,因此出现了混淆。如果您不想将blob公开,该怎么办?您需要生成SAS令牌并将其添加到查询字符串中
http://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>