Click here to Skip to main content
15,895,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to pass value from Windows Form Application to Web Form Application(ASP.Net)? For example the user session from Windows Form App passed to Web Form App.

What I have tried:

So far, I haven't try anything yet since I'm not very sure about that. I tried searching everywhere on internet also but I couldn't find one. So I am wondering either it's possible or not. If it's a yes, could somebody give me an example on how to do that. Thank you.
Posted
Updated 14-Mar-16 18:47pm

1 solution

You can use HttpWebRequest to implement your requirement, and append all the values you want to post into a single string for the request. Here is the code snippet:

In windows app:
C#
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.yoursite.com");
request.Method = "POST";

formContent = "FormValue1=" + someValue +
    "&FormValue2=" + someValue2 +
    "&FormValue=" + someValue2;

byte[] byteArray = Encoding.UTF8.GetBytes(formContent);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = HttpUtility.UrlDecode(reader.ReadToEnd());
//You may need HttpUtility.HtmlDecode depending on the response

reader.Close();
dataStream.Close();
response.Close();

In VB page load method:
VB
Protected Sub Page_Load(sender As Object, e As EventArgs)
	For Each key As String In HttpContext.Current.Request.Form.AllKeys
		Dim value As String = HttpContext.Current.Request.Form(key)
	Next
End Sub
 
Share this answer
 
Comments
Member 12389716 15-Mar-16 3:31am    
fhufyrtf
[no name] 15-Mar-16 4:52am    
What?

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