locked
Absolute Uri when querying the images source from the server RRS feed

  • Question

  • Dear Gurus!

    In silverlight 5 application I want to show on client side some images of the object, wich are located in some folder with absolute address , for example D:/Images. Now I use images from the folder Images near the clientBin folder of the application and use next code:

                Uri myUri = new Uri(App.Current.Host.Source, "../Images/edds.jpg");
                itemImage = new BitmapImage(myUri);

    and it works. How to change code when images are in some arbitrary folder , not in application?


    • Edited by ATerentjev Saturday, June 20, 2015 8:34 PM
    Saturday, June 20, 2015 8:33 PM

Answers

  • Ok, no problem.

    You can create a virtual folder and point it to any location you like.

    It could actually be on a different machine if you really wanted to do that.

    Sounds like these are all on one server so that's pretty easy.

    You could have one of the folders inside the physical folder structure for one of these sites or you could have it totally separate.

    You use iis to add a virtual folder and point it at whatever location.

    As far as IIS is concerned that folder is the virtual one.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Sunday, June 21, 2015 1:08 PM
    Moderator

All replies

  • You can't do that. Or not in that way anyhow.

    The page is served by the web server.

    Silverlight can only read from the web site it's served by unless you do some crossdomain policy stuff.

    When you go get

     Uri myUri = new Uri(App.Current.Host.Source, "../Images/edds.jpg");

    What Silverlight does is says "hey iis... serve me a file from this virtual web folder you have... here" and it will only do so out SOME sort of web site.

    It won't serve any old file which isn't in a web site. Even then, it will not serve certain types of file.

    An arbritrary file doesn't sound like It's going to be part of any web site.

    You'd have to write a web service which ran on the server and went and got the file for you.

    Make a call to your web service. You could do that fairly easy with wcf but then you'd have to give the process wcf is running in authority to read any old file. That ought to start alarms ringing in your head.

    Serving arbitrary files is a web no no.  It's a web disaster waiting to happen.

    EG, those passwords in your web config aren't going to be so secure any more if you serve the file.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Sunday, June 21, 2015 8:56 AM
    Moderator
  • Thank you very much! It is pleased to receive a clear answer. 

    I will explain my problem more carefully.

    I need to have file storage where users can capture video or image of any object. Like in social sites. This storage should not be part of the project which is loaded as well as zap files. There are several sites that will use files from this storage. It should be a one place  with an absolute location on the server,  a place to which access can have multiple sites or users of other programs.

    P.S. Some more about my task. Some objects - bridges, roads, emergency situations must have some folder , in wich users of silverlight (while silverlight) application can load some pictures or videos. And other users should be able to see this files. Perhaps virtual directory  with an absolute location on the server can be connect to the site . Writes information in the directory can any other ways - for example through a ftp server.
    • Edited by ATerentjev Sunday, June 21, 2015 12:42 PM
    Sunday, June 21, 2015 12:22 PM
  • Ok, no problem.

    You can create a virtual folder and point it to any location you like.

    It could actually be on a different machine if you really wanted to do that.

    Sounds like these are all on one server so that's pretty easy.

    You could have one of the folders inside the physical folder structure for one of these sites or you could have it totally separate.

    You use iis to add a virtual folder and point it at whatever location.

    As far as IIS is concerned that folder is the virtual one.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Sunday, June 21, 2015 1:08 PM
    Moderator
  • Excellent, everything is clear!
    Sunday, June 21, 2015 5:43 PM
  • If you come back, could you please mark my post as answer?

    I can myself since I'm a moderator here, but it's preferable for the person who asks the question to do so.

    You should see a "mark as answer" link at the bottom of any post in a thread you start.

    Other than the initial question, that is.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Monday, June 22, 2015 7:40 AM
    Moderator