0

In the database we are storing paths, like "~/SubDir/2015/A/B/1.jpeg".

How do I easily convert that to my full website url, like http://www.mywebsite.com/SubDir/2015/A/B/1.jpg?

Florian Greinacher
  • 14,066
  • 1
  • 32
  • 51
WebDevGuy2
  • 1,069
  • 1
  • 17
  • 34

2 Answers2

1

If you are creating img links, add the runat="server" attribute for the links to resolve correctly:

<img src="~/SubDir/2015/A/B/1.jpeg" alt="Desc" runat="server" />

This will then display images whether you are on a development, staging or production server...

IrishChieftain
  • 15,099
  • 7
  • 48
  • 91
0

You need to know the value you want to replace.

You could do it in SQL with the REPLACE() function, e.g.

SELECT REPLACE(ColumnName, '~', 'http://www.mywebsite.com') FROM Table

Or do it in C#:

string url = url.Replace("~", "http://www.mywebsite.com");
Dan Field
  • 19,501
  • 3
  • 49
  • 69