가장 단순한 것을 이루고 싶습니다. 즉, ac # 콘솔 응용 프로그램에서 aspx 페이지를 요청하면 aspx 페이지에서 C # 앱에 다시 문자열을 제공해야합니다.
나는 주위를 많이 수색했지만 실제로 아무것도 찾을 수 없었습니다 :(
내 페이지가 www.example.com/default.aspx라고 가정 해 보겠습니다. 그리고 내 C # 앱에서 해당 페이지에 요청을하면 해당 페이지가 "Hello"라는 문자열 만 반환해야합니다.
아래에서 내가 어떻게해야한다고 생각하는지에 대한 의사 코드를 작성했습니다.
C # 앱
public static void Main(string[] args)
{
//1. Make request to the page: www.example.com/default.aspx
//2. Get the string from that page.
//3. Write out the string. (Should be "Hello")
Console.ReadLine();
}
.aspx 코드
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string text = "Hello";
//1. Return the "text" variable to the client that requested this page
}
}
System.Net.WebClient 클래스 사용
var html = new WebClient().DownloadString("http://www.example.com/default.aspx"));
Console.Write(html);
웹 페이지는 텍스트를 다음과 같이 출력해야합니다.
Response.Write(text);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다