Search code examples
asp.netc#-4.0facebook-apps

How to Imgae Url path correct by code for share image on facebook


I'm getting a image path with using this code below:

string strUrl = Server.MapPath(Url.ToString());

result is bellow:

E:\\Projects\\Project\\ProjectFolder\\Ptoject\\Image\\Aliisza.jpg

I want to get path like this for share photo on facebook like this

http://wwww.domain.com/Image/Aliisza.jpg

which can help me to hare Image on facebool with facebook app im doing this code in c# please let me know how can i can make this Image path like I want to hit on facebook for share. give you some sample of code to do this task done. Hope some buddy have a solution to do this task and hit image Url like i want.

Thank you


Solution

  • First of all ServerMap path is working fine as expected, it will give rootlevel path.

    To get url, you need to append it to the domain name.

    What best you can do is put the value in config file and use it.

    Also you can try Directory.GetParent(fileName).FullName;

    To get Parent folder name.

    This is concept to decide what approach you choose.