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
  • 13,628
  • 1
  • 31
  • 50
WebDevGuy2
  • 935
  • 1
  • 15
  • 30

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,072
  • 7
  • 47
  • 90
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
  • 18,334
  • 2
  • 43
  • 63