来自Azure网站的Azure存储访问 [英] Azure Storage access from Azure web site

查看:71
本文介绍了来自Azure网站的Azure存储访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从Visual Studio 2015 iisexpress愉快地运行的网站中内置了一个Blob存储树显示.将文件上传到Azure网站时,带有存储树的页面会导致浏览器错误重定向过多".因为它运行在Azure上,所以有什么不同吗?我是Azure新手.

I have a blob storage tree display built into a website running happily from the Visual Studio 2015 iisexpress. When the files are uploaded to an Azure web site, the page with the storage tree causes a browser error "Too many redirects". Is there anything different because it's running on Azure? I'm an Azure newbie.

这是进行连接的代码

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Microsoft.WindowsAzure.Storage;
@using Microsoft.WindowsAzure.Storage.Auth;
@using Microsoft.WindowsAzure.Storage.Blob;
@using System.Web.Configuration;
@using System.Text;
@using System.Linq;

@{
    string accountName = WebConfigurationManager.AppSettings["AzureStorageAccountName"];
    string accountKey = WebConfigurationManager.AppSettings["AzureStorageAccessKey"];
    string rootContainer = WebConfigurationManager.AppSettings["AzureStorageRootContainer"];

    try {
        StorageCredentials creds = new StorageCredentials(accountName,accountKey);
        CloudStorageAccount account = new CloudStorageAccount(creds,useHttps :true);

        CloudBlobClient client = account.CreateCloudBlobClient();

        IEnumerable<CloudBlobContainer> containerList = client.ListContainers(rootContainer);

        foreach(var container in containerList) {    
            var blobCount = container.ListBlobs().Count();
            HtmlString listing = getContainerDirectories(container.ListBlobs());

            @Html.Raw(listing); 
        }
    } catch(Exception ex) {
        <p>@Umbraco.GetDictionaryValue("[Global] Sorry try again")</p>
    }
}

TIA

推荐答案

来自comment2answer:您需要发布一些代码,看来该网站将您重定向到了重定向的页面,依此类推....因此,它可能在您的登录页面或错误页面中有一些配置错误.检查您何时进行重定向以及loginUrl配置等.我猜想当您找到重定向您的代码时,您将获得如何解决该问题的答案.多次重定向与您使用Windows-azure-storage的事实无关100%

From comment2answer: You need to post some code, it seems the site redirects you to a page that redirects and so on ... . So it is probably have some configuration error in your logon page or error page. Check when you do a redirect and your loginUrl configuration etc. I guess when you find the code that redirects you, you will have the answer on how to fix it. The to many redirects is 100% not related with the fact you are using windows-azure-storage

这篇关于来自Azure网站的Azure存储访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆