WebDevGuy2
WebDevGuy2

Reputation: 1249

How convert tilde (~) path the full website url

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?

Upvotes: 0

Views: 871

Answers (2)

IrishChieftain
IrishChieftain

Reputation: 15253

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...

Upvotes: 1

Dan Field
Dan Field

Reputation: 21641

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");

Upvotes: 0

Related Questions