Click here to Skip to main content
15,125,972 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to save images from one project to another project. My project 1 is a main project and the other is API project. The image folder is in the main project and I have to save images from API to main project.Both are hosted different domain. Is it possible for to do same.I Want to save Images from http://localhost:9634/ to http://localhost:3243/ it takes first one url

What I have tried:

string ReferanceId ="HSA90232";
string basePath ="/Images/City/";
string PointQRCode ="PointQRCode";
string QrCode="3209323";

var url = string.Format("https://chart.googleapis.com/chart?cht=qr&chl=" + ReferanceId + "&chs=160x160&chld=L|0");

WebResponse response = default(WebResponse);
Stream remoteStream = default(Stream);
StreamReader readStream = default(StreamReader);
WebRequest request = WebRequest.Create(url);
response = request.GetResponse();
remoteStream = response.GetResponseStream();
readStream = new StreamReader(remoteStream);
//Creating Path to save image in folder
System.Drawing.Image img = System.Drawing.Image.FromStream(remoteStream);

string imgpath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(basePath + PointQRCode), QrCode);
var exists = System.IO.Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(basePath + PointQRCode));
if (!exists)
{
System.IO.Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(basePath + PointQRCode));
}
img.Save(imgpath); //// Want to save Images from http://localhost:9634/ to http://localhost:3243/ it takes first one url 
response.Close();
remoteStream.Close();
readStream.Close();
Posted
Updated 22-May-19 3:08am
v2
Comments
lmoelleb 22-May-19 6:19am
   
You need to ask a question. Telling what you want and dumping some code on us is not asking a question. Debug your code, find out which line does not behave as you expect. Examine any errors (google them if you do not understand). If you still do not know why it fails, then ask a question including all details - the error you get, which line you get it on, what you expected the code to do, ...

1 solution

I thinkt he only way you can call another app in your solution is to run two instances of visual studio with the same solution loaded, start your api application in the first VS, and then go to the 2nd VS and run your web app.

To make things easy on yourself, specify a port number in your api project properties so you can always count on it to be the same.
   
Comments
Richard Deeming 24-May-19 15:03pm
   
Visual Studio has supported debugging multiple startup projects since at least VS2015:
Debug multiple processes - Visual Studio | Microsoft Docs[^]
#realJSOP 25-May-19 9:32am
   
Even if they're not in the same solution?
Richard Deeming 29-May-19 6:21am
   
No, they'd have to be in the same solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900