Hello,
Win App:
takes a value from a textbox1 and send it throw parameter to a method in the website called WebDisplay(textbox1.text)
Web App:
recives the value of the parameter.
so how can i do that..?
thanks!
Hello,
Win App:
takes a value from a textbox1 and send it throw parameter to a method in the website called WebDisplay(textbox1.text)
Web App:
recives the value of the parameter.
so how can i do that..?
thanks!
Brief summary and next steps tied to the replies from this thread.
As asked: you can either send the textbox value directly in an HTTP request (quick) or call a method on the site (cleaner). pointed to the simple URL approach and suggested exposing a web method; both are valid. Missing from those replies were practical tips on encoding, security, threading on the WinForms side, and a modern, maintainable pattern you can use today.
Recommended approach (practical and robust)
Minimal examples (WinForms client + ASP.NET Web API)
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
async Task SendValueAsync(string value)
{
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(10) };
var json = JsonSerializer.Serialize(new { text = value });
using var content = new StringContent(json, Encoding.UTF8, "application/json");
var resp = await client.PostAsync("https://your-site/api/values", content);
resp.EnsureSuccessStatusCode();
} public class ValuesController : ApiController
{
[HttpPost]
public IHttpActionResult Post([FromBody] RequestModel model)
{
if (string.IsNullOrWhiteSpace(model?.Text)) return BadRequest("empty");
// process model.Text
return Ok(new { status = "ok" });
}
}
public class RequestModel { public string Text { get; set; } } Troubleshooting & cautions
Jump to Post— IdanS 12Send the value in the query string like this:
Name of web page.aspx?parm=valueIn the web app when the page loads read the parm like this:
this.Request.Params["parm"]and use it how you want...!
Send the value in the query string like this:
Name of web page.aspx?parm=value In the web app when the page loads read the parm like this:
this.Request.Params["parm"] and use it how you want...!
how the win app sends and recive from the web app
Web App:
Create a web service in the web application with WebDisplay as a WebMethod.
Win App:
Add web reference to the windows application.
Call WebDisplay method and pass the textbox.text as parameter.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.