Windows Azure网站和Blob存储中的静态html [英] Windows Azure Website and static html in Blob storage

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

问题描述

因此,我在Azure网站上发布了.NET MVC应用,当单击相应的超链接时,该应用应提供存储在blob容器中的静态html页面.

So I have a .NET MVC app published in an Azure Website which should serve static html pages stored in a blob container when clicking on a corresponding hyperlink.

我的问题是:

  1. 在Azure中访问Blob的方法是 https://blobtest.blob.core.windows.net/container/htmlpage1.html,但是,特殊的部分是当我登录到Azure网站时,URL为就像是: http://azuretestwebapp.azurewebsites.net/user123 ,如果我单击在我的html blob的超链接上,它无济于事,但通常会将我带到Blob天蓝色站点(当然可以).因此我想知道是否有是一种具有类似于以下内容的网址的方法: http://azuretestwebapp.azurewebsites.net/user123/container/htmlpage1.html 考虑到html页存储在Azure中的其他位置.
  2. 如果使用Azure网站或通过存储不可行Blob中的静态html页面,哪种方法更好?
  1. The way to access a blob in Azure is https://blobtest.blob.core.windows.net/container/htmlpage1.html, however the peculiar part is when I login into my Azure Site and the url is something like: http://azuretestwebapp.azurewebsites.net/user123 and if I click on a hyperlink to my html blob it can't help but normally take me to blob azure site (well of course). Therefore I am wondering if there is a way to have a url similar to this: http://azuretestwebapp.azurewebsites.net/user123/container/htmlpage1.html considering that the html pages are stored elsewhere in Azure.
  2. If this is not feasible using an Azure Website or by storing static html pages in Blob, what would be a better approach?

提前感谢您的时间.

推荐答案

您可以修改站点的web.config,以使用重定向规则将对静态页面的请求转发到Blob存储.然后,静态内容将存储在Blob存储中并从中提供.

You can modify your web.config for your site to forward requests for static pages to blob storage using a redirect rule. Then the static content will be stored in and served from blob storage.

将以下内容放置在名为web.config的文件中(或修改您现有的web.config),并将web.config放置在网站内容旁边网站上的site/wwwroot文件夹中.

Place the following in a file named web.config (or modify your existing web.config) and put the web.config in the folder site/wwwroot on your website, next to the site content.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="static" stopProcessing="true">
          <match url="static/(.*)" />
          <action type="Rewrite" url="https://blobtest.blob.core.windows.net/static/{R:1}" />          
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

这篇关于Windows Azure网站和Blob存储中的静态html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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