这个 ASP.NET 重写有什么问题?

发布于 2024-09-03 10:20:46 字数 194 浏览 2 评论 0原文

实际上它是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谈下烟灰 2024-09-10 10:20:46

使用 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

你与清晨阳光 2024-09-10 10:20:46

默认情况下,图像不由 ASP.NET 处理(至少在 IIS 上)。您是否能够确认图像扩展是由 ASP.NET 处理的,而不是直接提供的?

另外,稍微修改一下代码:

string newpath = "~/App_Data/public" + path;
context.RewritePath(newpath);

并检查 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:

string newpath = "~/App_Data/public" + path;
context.RewritePath(newpath);

And check the value of newpath to make sure it's a well-formed path. If path is not prefixed with a path delimiter then that may also be the cause of your woes.

仄言 2024-09-10 10:20:46

mono ATM 似乎不支持此功能。 HttpContext.Rewrite 是,但重写文件不是。

It looks like this isnt supported in mono ATM. HttpContext.Rewrite is but rewriting to files is not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文