我正在使用Pannellum js在我的MVC应用程序中显示图像。目前我正在使用本地文件服务器来存储图像并显示相同的内容。现在我已将所有图像移至Azure BLOB Container。与Pannellum JS连接到Azure的CORS问题BLOB MVC
的问题是我得到CORS错误,而从BLOB检索图像:
我已签净许多解决方案。但他们都没有工作是我的情况。我已经使用“createCORSRequest”为XMLHttpRequest设置了全局CORS规则,但无法工作。我也为我的方法设置了<add name="Access-Control-Allow-Origin" value="*" />
并设置了。
仅供参考,我的BLOB URL,https://inspecttv.blob.core.windows.net和我的网站是https://www.inspectanytime.tv/
下面是从那里我传递BLOB图像JSON和在某种程度上的JavaScript代码。
string Json = "[";
string Photos = "";
//string SiteUrl = "http://inspectanytime.azurewebsites.net";
foreach (tblAT_PropertyImage tbl in LST)
{
string thumbimage = tbl.Photo.ToString().Substring(0, tbl.Photo.ToString().LastIndexOf('.')) + "_thumb" + tbl.Photo.ToString().Substring(tbl.Photo.ToString().LastIndexOf('.'));
string FullImage = AzureCloud.GetFileFromCloud(tbl.Photo, AzureCloud.AzureContainers.inspectimagefiles); // SiteUrl + "/ViewerImage.ashx?p=" + tbl.Photo;
string Thumb = AzureCloud.GetFileFromCloud(thumbimage, AzureCloud.AzureContainers.inspectimagefiles); //SiteUrl + "/ViewerThumb.ashx?p=" + tbl.Photo;
string SinglePhoto = "{\"image\":\"" + FullImage + "\",\"imageThumb\":\"" + Thumb + "\",\"description\":\"" + tbl.Tag + "\",\"Address\":\"" + Address + "\"}";
if (Photos != "")
{
Photos += "," + SinglePhoto;
}
else
{
Photos += SinglePhoto;
}
}
Json += Photos;
Json += "]";
专家提示:要求紧迫性是获得降薪的好方法,不要这样做!请[阅读本社区讨论](http://meta.stackoverflow.com/q/326569/472495)。 – halfer
您是否手动装配JSON?在asp.net中应该有一个库来为你做这件事 - 你可以交换吗? – halfer
@halfer我正在使用'https://github.com/mpetroff/pannellum',这个JSON代码用于发送数据到本地文件的JS(我也会检查你的建议),这是与图片BLOB网址。 – ParthKansara