Skip to content

How i pass the value at server from client using webRequest

Amee Doshi

Asked Jun 27, 2015, 12:05 AM EDT1 answer
Share
LinkedInX
i can see the from at client side which is on server but i want to get the pass value server side plze help me
this is my code
client side
TypeScript
 try
            {
                // Create a new HttpWebRequest object.Make sure that
                //  a default proxy is set if you are behind a firewall.

                string hello = "amee";
                HttpWebRequest myHttpWebRequest1 =
                  (HttpWebRequest)WebRequest.Create(String.Format("http://192.168.2.50:96/default2.aspx?CartID={0}&ProductID={1}", name, hello));
                //onse.Redirect(String.Format("ViewCartItems.aspx?CartID={0}&ProductID={1}", id, productid));
                myHttpWebRequest1.KeepAlive = false;

                // Assign the response object of HttpWebRequest to a HttpWebResponse variable.
HttpWebResponse myHttpWebResponse1 =
Java
                  (HttpWebResponse)myHttpWebRequest1.GetResponse();

                Console.WriteLine("\nThe HTTP request Headers for the first request are: \n{0}", myHttpWebRequest1.Headers);
                Console.WriteLine("Press Enter Key to Continue..........");
                Console.Read();

                Stream streamResponse = myHttpWebResponse1.GetResponseStream();
                StreamReader streamRead = new StreamReader(streamResponse);
                Char[] readBuff = new Char[256];
                int count = streamRead.Read(readBuff, 0, 256);
                Console.WriteLine("The contents of the Html page are.......\n");
                while (count > 0)
                {
                    String outputData = new String(readBuff, 0, count);
                    Console.Write(outputData);
                    count = streamRead.Read(readBuff, 0, 256);
                }
                Console.WriteLine();
                // Close the Stream object.
                streamResponse.Close();
                streamRead.Close();
                // Release the resources held by response object.
                myHttpWebResponse1.Close();
                // Create a new HttpWebRequest object for the specified Uri.
                //HttpWebRequest myHttpWebRequest2 =
                //  (HttpWebRequest)WebRequest.Create(String.Format("http://192.168.2.50:96/default2.aspx?CartID={0}&ProductID={1}", name, hello));
                //myHttpWebRequest2.Connection="open";

                //// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
                //HttpWebResponse myHttpWebResponse2 =
                //  (HttpWebResponse)myHttpWebRequest2.GetResponse();
                //// Release the resources held by response object.
                //myHttpWebResponse2.Close();
                //Console.WriteLine("\nThe Http RequestHeaders are \n{0}", myHttpWebRequest2.Headers);
                Console.WriteLine("\nPress 'Enter' Key to Continue.........");
                Console.Read();
                Console.ReadKey();
            }
            catch (ArgumentException e)
            {
                Console.WriteLine("\nThe second HttpWebRequest object has raised an Argument Exception as 'Connection' Property is set to 'Close'");
                Console.WriteLine("\n{0}", e.Message);
                Console.ReadKey();
            }
            catch (WebException e)
            {
                Console.WriteLine("WebException raised!");
                Console.WriteLine("\n{0}", e.Message);
                Console.WriteLine("\n{0}", e.Status);
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception raised!");
                Console.WriteLine("Source :{0} ", e.Source);
                Console.WriteLine("Message :{0} ", e.Message);
                Console.ReadKey();
            }
 
 
 
using this code i will able to see defualt.aspx page at hear
 
 server side
 
 
 defualt.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
Code
 TextBox2.Text = Request.QueryString["CartID"];
insert in table
}
when client is request i want autometically insert in database from server side
 
 
 
 
 defualt.aspx
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ATM ID
FileName
runat="server" />
 please help me

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    if another method suggest me also
    0