我有一个.NET应用程序,在一个文件夹/ images /中包含500多个图像。在我的表示层中,我使用相对路径引用这些图像。
<img src="/images/testimage.png" />
我现在想要将这些图像从Azure blob存储容器中移除。所以我的新路径需要明确定义资源的完整URI。
<img src="https://myarea.blob.core.windows.net/images/testimage.png" />
当我发现我可能能够使用IIS重新路由这些请求时,我正要进行站点范围的查找替换。所以我的问题是IIS可以拦截对/ images文件夹的请求并在提供文件之前为新URI添加前缀吗?如果是这样,除了从新位置获取图像所花费的时间之外,这会给应用程序带来什么类型的延迟?我的大多数图像文件都是.png,.gif和.jpeg,通常为5-20kb,用于模板,按钮和一般格式。
答案 0 :(得分:1)
使用URL Rewrite,您可以执行此操作。
匹配/ images / *并重定向到https://myarea.blob.core.windows.net/images/ ...
<system.webServer>
<rewrite>
<rules>
<rule name="images to azure" stopProcessing="true">
<match url="/images/(.*)" />
<action type="Redirect" url="https://myarea.blob.core.windows.net/images/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>