Forums - C# Corner

Forum guidelines
umit alp

umit alp

  • 1.5k
  • 3
  • 277

from MVC send parameters with handler.ashx to c# exe

Jun 1 2017 2:59 AM

hi i have send string parameters in my MVC view javascript button with ajax look like this;

**  $.ajax({ 
 url: 'myGenericHandler.ashx', 
type: 'GET', 
data: {'param1':'parameter','param2':'parameter2'}, 
success: function (data) { 
alert("Success :" + data); }, 
error: function (errorText) { 
 alert("Warning"); } });


when i take myGenericHandler.ashx param1 and param2 sending to my WinForms C# myapp.exe on_load class which i get values with httpwebrequest.create(../myGenericHandler.ashx) ......

myGenericHandler.ashx code public void ProcessRequest(HttpContext context) {

 try { 
string param1 = context.Request.QueryString["param1"]; 
string param2 = context.Request.QueryString["param2"]; 
context.Response.ContentType = "text/plain"; 
 context.Response.End(); }

Winform C# myapp.exe form load

private void FDesktop_Load(object sender, EventArgs e) { 
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:xxxx/myGenericHandler.ashx"); 
WebResponse wr; 
wr = req.GetResponse(); 
StreamReader str = new StreamReader(wr.GetResponseStream()); 
string t = str.ReadToEnd(); 
toolStripLabel1.Text = t; }

myapp.exe start in MVC view

string path = @"C:\......\myapp.exe"; 
Process p = Process.Start(path); 
p.WaitForExit(); }

My problem is in myGenericHandler.ashx load in MVC view param1 and param2 have values.But when i Proccess.Start(myapp.exe); myGenericHandler.ashx param1 and param 2 values are can i start same time with myapp.exe myGenericHandler.ashx and view one.or any idea from MVC url ?param  to c# .exe.  thank you.

Answers (2)