ASP.NET VirtualPathProvider 与静态文件问题
我在 Windows 7 上运行 IIS 7.5。我的 ASP .NET 应用程序使用 VirtualPathProvider。大多数文件(aspx 页面)都由我的 VirtualPathProvider 返回并呈现良好。静态文件(css/图像)不是。如果我尝试直接浏览它们(或者它们被我的虚拟 aspx 页面引用),它们会产生 HTTP 404 错误。
我已经验证了我的 web.config 已为静态文件类型注册了正确的处理程序。
奇怪的是:
如果我尝试浏览到一个非虚拟 gif 文件(实际存在于网站根目录下的文件系统中的文件),它会呈现正常。
如果我在 Visual Studio 中而不是 IIS 中使用 WebDev 运行,则虚拟 gif 文件呈现良好。
在调试模式下,在
VirtualPathProvider.GetFile
中,我可以看到我的VirtualPathProvider在页面返回404错误之前返回了虚拟gif文件的完全有效的实例...所以我知道我的VirtualPathProvider工作正常。
注意,当我说 IIS 时,我并不是指在已部署的环境中。我只是说将项目设置切换为使用 IIS 而不是 WebDev。
有什么想法吗?
谢谢。
I'm running IIS 7.5 on Windows 7. My ASP .NET application uses a VirtualPathProvider. Most of the files (aspx pages) are returned and rendered fine by my VirtualPathProvider. Static files (css/images) are not. They yield a HTTP 404 error if I try to browse to them directly (or if they're referenced by my virtual aspx page)
I've verified my web.config has the correct handler registered for static file types.
What's weird is this:
If I try to browse to a non-virtual gif file (one that actually exists on the file system under the website root), it renders fine.
If I run using WebDev in Visual Studio instead of IIS, the virtual gif files render fine.
In debug mode, in
VirtualPathProvider.GetFile
, I can SEE my VirtualPathProvider returning a perfectly valid instance of my virtual gif file right before the page returns the 404 error...so I know my VirtualPathProvider is working just fine.
NOTE, when I say IIS, I don't mean in a deployed environment. I just mean switching the project settings to use IIS instead of WebDev.
Any ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
...和 答案:
...and answer: