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!

Dani AI

Generated

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)

  • For one-off, non-sensitive values the simplest route is an HTTP GET with an encoded parameter. Use it only for very small, public data.
  • For anything larger, structured, or sensitive, create a small HTTPS REST endpoint on the website and POST JSON from the WinForms app. This keeps data out of logs/URLs, scales to more fields, and is easy to secure and version.
  • Prefer Web API (or minimal APIs) over legacy ASMX for new work. If you must use older frameworks, WebClient or HttpWebRequest will work, but HttpClient (async) is the modern choice.

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

  • Always use HTTPS for anything sensitive. Do not put secrets in URLs.
  • Run network calls off the UI thread (async/await or Task.Run) to avoid freezing the form.
  • URL-encode values if you use GET; validate and limit input size on the server.
  • Test the endpoint with Postman or curl first, and add try/catch, timeouts and retries on the client.

Recommended Answers

All 3 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.