1

I am using resolveUrl to call a virtual directory specified in my web config. Recently my error log gave me a issue to where it prepened a long string to this path. So to be clear it resolved the proper url but added a string that was over 240 chars long. I am wondering if anyone has ever had an issue with this.

Here is the call:

string originalImage = ResolveUrl(m_photoVirtualPath) + "/" + table.Rows[0]["Key"].ToString() + "/" + table.Rows[0]["LargeImageFileName"].ToString();

Here is the output error:

(F(7teHGa3jtAWTm0cKjtcKe8aKQMb99ykEWnc2c8L7RGHP28aRwzXYDhA8vWHRepIqFN67FGtHRN41v3kiseUsbMoNZqUDgS9h7g8acMSFRDPTYxbM3UA2pUXAUzWJcCWU4A3oVlFz6YoAqXVCAGNJiGbUiWdjcsREGNAkdQHkzX6SjCf12QonsibppUVPiean-saajTAzQjgoRK1qnFactg2))/storage-pub/Photo/2901502/40719_19760_2903337.jpg

the /storage-pub/Photo is the correct resolved url shown in bold above and the directories after are also correct but I have no idea what the string is before the resolved url.

Coding Mash
  • 3,338
  • 5
  • 24
  • 45
Andrew Brower
  • 1,257
  • 2
  • 9
  • 10

2 Answers2

1

You can try with Server.MapPath

string originalImage = Path.Combine(Server.MapPath(m_photoVirtualPath) , table.Rows[0]["Key"].ToString() , table.Rows[0]["LargeImageFileName"].ToString());
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
  • I could but there is no reason that I would need the absolute path not only that but it is a virtual directory so it would not lead me to the correct location. Correct me if my thinking is wrong. Plus I am resolving the location just fine just not sure about the prepended string. Is it something IIS does when something going wrong etc. – Andrew Brower Oct 10 '12 at 18:45
  • you need relative path in order to bring flexibility, in you deploy your package – Aghilas Yakoub Oct 10 '12 at 18:46
  • Server.MapPath would return me a absolute location. Maybe it would help if I gave you more context. This is for a url redirection for instance http://_url_/Handler/Handler.ashx?Mode=Sepia&ImgSrc=/storage-pub/Photo/2901502/40719_19760_2903337.jpg. Therefore an absolute path returned for sever.mappath would be useless. – Andrew Brower Oct 10 '12 at 18:52
0

It turns out after some debugging that it was the cookie string that was getting pre-appended to the URL. Still not sure as to why or how it happened but by using the tracing features in vs2010 I was able to view all my cookie and session strings and from there I was able to compare them to the string in the URL. Thank you all for your help and guidance.

Andrew Brower
  • 1,257
  • 2
  • 9
  • 10