Reputation: 209
I have two asp.net applications hosted on the same server. I need to access files uploaded in one application from another. For instance, I have my original files in www.crm.sample.com/ImportedFiles/ and I want to access or download those files from www.gmc.sample.com. How can I achieve it.
Upvotes: 2
Views: 3816
Reputation: 8265
You can do it with classes in System.IO
namespace. Create a web page in your app that instead of rendering HTML, sends desired file's bytes to the client:
var bytes = File.ReadAllBytes("d:\\Site1\\img1.jpg");
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.ContentType = "image/jpeg";
Reponse.End();
you can use QueryString
to send parameters that show witch file the client wants.
Upvotes: 2
Reputation: 8232
Personally I would create some virtual folders in IIS on Site 1, which map to the download destination in Site 2. Then by calling Server.MapPath("~/site2download")
on the virtual folder and using the System.IO
namespace you can read the files and do whatever you like from there.
Heres some info on how to create a virtual directory in IIS 7
Upvotes: 0