views:

24

answers:

2

How do you resolve a url like "../../images/test.png" to "http://yoursite.com/images/test.png" in a static asp.net web method?

A: 

look in HttpContext.Current.Request

Sergej Andrejev
+1  A: 

Here is a blog entry from Rick Strahl that might help: http://www.west-wind.com/weblog/posts/154812.aspx

Daniel Dyson
jip, that is a really good article, but if I understand the code correctly it would not work for situations where your have ../../../ etc in the url. but I could be wrong
Daniel Brink
Is the images folder in the root directory? If so, replace ../../ with ~/ That is what the resolver is supposed to do, change ~/ to the appropriate path, depending on the nesting level of the page.
Daniel Dyson
i cannot replace ../../ with ~/ as any number of ../ relative paths to various pages and files can be passed to my static webmethod. i therefore need a way to convert a relative path such as ../1/2/3/4/page.aspx to http ://abc.com/a/b/s/1/2/3/4/page.aspx
Daniel Brink
Ok, I think you need to provide more examples of what you need to do in your question
Daniel Dyson