Hello, I have a Silverlight 4 web site with DASP, it is deployed in beta and that has gone well. I need to read a text file from the web server, do some string replaces, and put the changed file back. The file is located in the /Docs folder below the root of my site. I am using HttpWebRequest (because evidently SL does not support FtpWebRequest). For starters I am running this within the development environment using an absolute Uri. I have been trying this with no luck and have some questions: The exception information I receive is sketchy but indicates a poorly formed URI (the error is Exception from HRESULT: 0x80072EE5). Is there a tool that would allow gathering of better error information? I'm using Fiddler but that isn't giving me anything in this case. Here is my uri string, can anyone tell me what the problem could be? "http://DASP Control Panel Login:DASP Password@mydomain.com/Docs/Text.txt" I have also tried: "http://DASP Customer ID|DASP Control Panel Login:DASP Password@mydomain.com/Docs/Text.txt" I tried a more generic Uri without authentication information and the exception was a security violation. That seemed (maybe) to confirm that my request is getting to the web server, but that my uri including the authentication information was being rejected for some reason other than the security. Thank you for any information! Randy
Hi, I've seen this covered in a lot of blogs since Silverlight v2 but have never tried it. Are you using a uri builder first? And, why the username and PW? All the best, Mark
Thanks for replying, Mark. I have tried this with and without using the UriBuilder. The UriBuilder will add a pound sign before the "fragment" which I believe should be the file name (text txt). In any event, neither have worked for me. I'm running this in the development server -- the alternative I guess would be to publish the site each time I try a different tack. Since the development server isn't hooked to the web server I figure that authentication is required. I assume that with the live site the authentication would have already been done and relative paths could be used. Maybe running in the development server is a dead end when attempting HttpWebRequest. I'm going to try it by publishing the site and see if that makes any difference. Thank you! Randy
OK -- I published the site and the OpenReadAsync worked without a hitch (without a second authentication and using relative pathing). The moral of the story would appear to be: don't try connecting to your live server from within the development server.
There's one thing I don't understand... If I run the OpenFileAsync without loggin in first, it still works. Shouldn't it fail? I have directory browsing turned off for what that's worth. Randy
Hi Randy, I'm willing to look into this for you but honestly I'm swamped right now. Have you considered posting in the official Silverlight.net forums? As for Authentication and Directory Browsing, did you get a handle on that part? All the best, Mark
Hi Mark, Thanks for your message. Yes, I can look into this on my own and I'll post what I find. I see that attemping to navigate directly to my /Docs folder via URL in the browser address bar doesn't work. What I think this means is that the web site itself must have full trust in its own domain, so to speak. The code doesn't have to authenticate itself. What the application designer has to do is *simply* ensure that site features are available to authenticated users only. Randy
Hope you get it done, that isn't the easiest thing to diagnose in SL, can be frustrating I know. All the best, Mark
I always use the WebClient class for reading and writing files from my Website, specifying full URI's just like you are. Never have a problem.
Thanks for posting. I've been working with the webclient class also since making this post - openreadasync and openwriteasync specifically. The read is working for me but not the write. Do you by chance have a link to sample code for using webclient? Thanks.
Actually, I'm only using OpenReadAsync. Haven't tried OpenWriteAsync. Sorry. Anything I have to post to my Website I do to my database. I also use IsolatedStorage a lot. Between the database and IsolatedStorage I've never had the occasion to programmatically store information directly on the Website. Probably a different way of managing the Website.