使用托管 Web 核心在 Windows Azure Web 角色中提供 .ogg
我有一个使用托管 Web 核心的 Azure Web 角色(即在 ServiceDefinition.cdef 中注释掉),但我似乎无法注册要提供的 .ogg 的 mimeType。我做了很多搜索并找到了一些建议的解决方案,但似乎没有任何效果。
一种解决方案建议添加 自定义 mime 类型在 web.config 中。当在我的本地 IIS(即不在 Azure 中)上将 Web 角色作为 Web 应用程序运行时,此方法有效,但当我在 Azure 中运行它时,它不起作用。 .ogg 返回 404.0 错误(在 fiddler 中,它的 Content-Type 为 text/html;charset=utf-8)。
另一个建议是在 ServiceDefinition.cdef 中注册一个启动任务,该任务将运行一个 cmd 文件,该文件将调用 appcmd.exe 来设置 mimeType(例如 %windir%\system32\inetsrv\appcmd.exe set config /section: staticContent /+"[fileExtension='ogg',mimeType='audio/ogg']"
).同样,这不起作用。
似乎其他人在尝试提供其他静态内容类型时已经使用这些方法取得了成功。我对为什么它对他们有效而不对我有效的唯一猜测是,他们在完整 IIS 模式下运行 Azure,而我在托管 Web 核心中运行。
任何帮助将不胜感激。
I have an Azure Web Role that is using the Hosted Web Core (i.e. is commented out in ServiceDefinition.cdef) and I can't seem to register the mimeType for .ogg to be served. I've done quite a bit of searching and found some suggested solutions but nothing seems to work.
One solution suggested adding the custom mime type in the web.config. This worked when running the web role as a web application on my local IIS (i.e. not in Azure), but when I run it in Azure, it does not work. The .ogg returns a 404.0 error (in fiddler, it has a Content-Type of text/html; charset=utf-8).
Another suggestion was to register a Start task in the ServiceDefinition.cdef which would run a cmd file which would call appcmd.exe to set the mimeType (e.g. %windir%\system32\inetsrv\appcmd.exe set config /section:staticContent /+"[fileExtension='ogg',mimeType='audio/ogg']"
). Again, this did not work.
It seems that others have been having success with these methods when trying to serve other static content types. My only guess as to why it worked for them and not for me is that they were running Azure in full IIS mode while I am running in the Hosted Web Core.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是 .ogg 文件实际上不存在。确保 .ogg 是 Visual Studio 项目的一部分并标记为“Build Action = Content”。 (在本地,这可能会起作用,因为 .ogg 文件与其余代码位于同一目录中,但在云中,它可能无法发布。)
(如果启用了远程桌面,这应该很容易测试只需远程进入其中一个实例并在 E:\ 驱动器上查找该站点,然后查看 .ogg 文件是否确实位于您期望的位置。)
My guess is that the .ogg file isn't actually there. Make sure the .ogg is part of your Visual Studio project and marked as "Build Action = Content." (Locally, this might just work because the .ogg file is in the same directory as the rest of your code, but in the cloud, it may not get published.)
(This should be pretty easy to test if you have Remote Desktop enabled for your app. Just remote into one of the instances and look around for the site on the E:\ drive. Then look to see if the .ogg file is actually there where you expect it to be.)