views:

48

answers:

3

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?

A: 

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

ggonsalv
It doesnt help. Its not a redirect. Its internal.
acidzombie24
A: 

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.

Quick Joe Smith
`string path = CleanPath(context.Request);` which just deletes everything after `?` and is the uri.path value. So it is always /whatever/andfolder/file.ext. This works in the visual studios webserver and cassini last time i checked.
acidzombie24
I have never heard of CleanPath, nor can I find it in the .NET libraries.
Quick Joe Smith
How does the modified code differ from the code posted in the question?
Jørn Schou-Rode
It is only so the poster can step through the code and inspect the result of the concatenation before feeding it to RewritePath.
Quick Joe Smith
CleanPath is my own. It looks like other ppl are having issues with mono+rewriting with files. I dont think its supported ATM. To be clear this works in ms asp.net
acidzombie24
@acidzombie24 - Well that's probably not too helpful to the OP without some source code or a link to this CleanPath of yours.
Quick Joe Smith
lol. maybe you didnt notice. The background color in my name is to note i am op.
acidzombie24
A: 

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

acidzombie24