问题
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.
My questions are:
- 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.
- If this is not feasible using an Azure Website or by storing static html pages in Blob, what would be a better approach?
Thank you in advance for your time.
回答1:
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.
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>
来源:https://stackoverflow.com/questions/30842249/windows-azure-website-and-static-html-in-blob-storage