1
Reply

how i pass the value at server from client using webRequest

Ask a question
Amee Doshi

Amee Doshi

9 years ago
472
1
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
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 =
(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)
{
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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server" method="get">
<div>
<table>
<tr>
<td>
ATM ID
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
FileName
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:FileUpload ID="FileUpload1"
runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="postdata" onclick="Button1_Click" />
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
 please help me
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Answers (1)