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,478
  • 1
  • 35
  • 53
WebDevGuy2
  • 1,159
  • 1
  • 19
  • 40

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,108
  • 7
  • 50
  • 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
  • 20,885
  • 5
  • 55
  • 71