Hello, I have a Silverlight 4 app, one task is to programmatically save some files on the server. The code is working on my local machine but not on the server. There is no error but the file does not get created. This code is inside a handler on the server side (I'm not sure how to debug this or throw an error when the code is running on the web server). All the handler does is write the file, so it seems that it might be a privlilege issue. I have not done any configuration of IIS in this regard. The directory for the files is /Docs/Cust under the root of the server. The directory has already been created, the program does not have to do that. Later I would like to create subfolders as needed. In my web.config I set the application as full trust and also set a location tag allowing access to the /Cust folder. So the question is: do I need to make changes in IIS to allow writing to the server in this fashion? Or, should I be looking at my application code for the problem? Thanks, Randy Here is the handler code: Code: Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim request As HttpRequest = context.Request Dim response As HttpResponse = context.Response Dim server As HttpServerUtility = context.Server Dim sFolder As String Dim sFileName As String = context.Request.Params("filename") sFolder = context.Server.MapPath("/Docs/Cust") If Not String.IsNullOrEmpty(sFileName) Then Using inputStream As Stream = request.InputStream 'If Not System.IO.Directory.Exists(sFolder) Then 'System.IO.Directory.CreateDirectory(sFolder) 'End If Using fs As New FileStream(sFolder & "/" & sFileName, FileMode.OpenOrCreate) Dim fileContent As Byte() = New Byte(inputStream.Length - 1) {} inputStream.Read(fileContent, 0, fileContent.Length) fs.Write(fileContent, 0, fileContent.Length) fs.Flush() End Using End Using response.Clear() response.[End]() End If End Sub
Solved -- wish I could say why! It's all working now, including creating directories on the fly. Randy
If anyone knows how to trap errors in a generic handler in Silverlight, I would appreaciate any information or links. Thanks, Randy
Hi, Do you Twitter? if so use it and the search Que. ;-) Just about every single Silverlight developer and MVP will see your post. All the best, Mark