这个 ASP.NET 重写有什么问题?
实际上它是 asp.net 的单声道版本,XSP。
在我的开始请求函数中,我检查 url 并在必要时重写。在一种情况下,
context.RewritePath("~/App_Data/public" + path);
当我尝试请求图像或任何内容时,我得到的是 404 而不是内容。为什么?
Actually its the mono version of asp.net, XSP.
In my begin request function i check the url and rewrite when necessary. In one case i do
context.RewritePath("~/App_Data/public" + path);
When i try to request images or anything i get a 404 instead of the content. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Fiddler 查看实际请求。如果路径被重写,图像可能必须引用为绝对路径。
但是可惜我没有使用 xsp 的经验,所以......
使用 fiddler 查看实际请求
Use Fiddler o see the actual request. If the path is being rewritten the images would probably have to referenced as an absolute path..
But alas I have no experince with xsp so ....
Use fiddler to see the actual request
默认情况下,图像不由 ASP.NET 处理(至少在 IIS 上)。您是否能够确认图像扩展是由 ASP.NET 处理的,而不是直接提供的?
另外,稍微修改一下代码:
并检查
newpath
的值以确保它是格式正确的路径。如果path
没有以路径分隔符为前缀,那么这也可能是您遇到麻烦的原因。Images by default don't get handled by ASP.NET (at least on IIS). Are you able to confirm that image extensions are being handled by ASP.NET and not being directly served up?
Also, modify the code slightly:
And check the value of
newpath
to make sure it's a well-formed path. Ifpath
is not prefixed with a path delimiter then that may also be the cause of your woes.mono ATM 似乎不支持此功能。 HttpContext.Rewrite 是,但重写文件不是。
It looks like this isnt supported in mono ATM. HttpContext.Rewrite is but rewriting to files is not.