Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:48:10+00:00 2026-06-07T10:48:10+00:00

I wanna make a post form in code behind. I have simple html post

  • 0

I wanna make a post form in code behind. I have simple html post is working but when I try make it WebRequest I can’t make it work.

Thanks for you time in advance.

this is working >

<!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>
    <title>Untitled Page</title>
</head>
<body>
<form action="http://www.pay-pos.com/test.php" method="post">
<textarea name="datafromuser">
<CC5Request><Name>Mert</Name><Password>123</Password><ClientId>1058</ClientId><IPAddress>213.456.654.456</IPAddress><Adress>asdsa</Adress><OrderId>123</OrderId><Type>Auth</Type>
<Number>4522115422659661</Number><ExpiresAy>01</ExpiresAy><ExpiresYil>13</ExpiresYil><Cvv2Val>123</Cvv2Val><Total>10</Total><Taksit></Taksit><Kdv>18</Kdv><BankaID>1</BankaID>
<TcKimlik>12345678912</TcKimlik></CC5Request>
</textarea>
<input type="submit" value="aaa" />
</form>
</body>
</html>

This isn’t working >

String ali = "<CC5Request><Name>Mert</Name><Password>123</Password><ClientId>xxxx</ClientId><IPAddress>213</IPAddress><Adress>asdsa</Adress>" +
                        "<OrderId>123</OrderId><Type>Auth</Type><Number>1234567891234567</Number><ExpiresAy>01</ExpiresAy><ExpiresYil>13</ExpiresYil><Cvv2Val>123</Cvv2Val>" +
                        "<Total>10</Total><Taksit></Taksit><Kdv>xx</Kdv><BankaID>1</BankaID><TcKimlik>12345678912</TcKimlik></CC5Request>";
                    WebRequest req = WebRequest.Create("http://www.pay-pos.com/test.php?datafromuser=" + ali);
                    req.Credentials = CredentialCache.DefaultCredentials;
                    req.Method = "POST";
                    HttpWebResponse loWebResponse = (HttpWebResponse)req.GetResponse();
                    Encoding enc = Encoding.GetEncoding(1254); 

                    StreamReader loResponseStream =

                       new StreamReader(loWebResponse.GetResponseStream(), enc);

                    string lcHtml = loResponseStream.ReadToEnd();
                    loWebResponse.Close();
                    loResponseStream.Close();

EDIT: EXPERIMENT 1

String postData = "Name=Mert" +
              "&Password=123" +
              "&ClientId=1058" +
              "&IPAddress=213.456.654.456" +
              "&Adress=asdsa" +
              "&OrderId=123" +
              "&Type=Auth" +
              "&Number=4522115422659661" +
              "&ExpiresAy=01" +
              "&ExpiresYil=13" +
              "&Cvv2Val=123" +
              "&Total=10" +
              "&Taksit=1" +
              "&Kdv=18" +
              "&BankaID=1" +
              "&TcKimlik=12345678912";

            string URI = "http://www.pay-pos.com/test.php";

            WebClient wc = new WebClient();
            wc.Headers["Content-type"] = "application/x-www-form-urlencoded";
            string HtmlResult = wc.UploadString(URI, postData);

EXPERIMENT 2

 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.pay-pos.com/test.php");
        request.Method = WebRequestMethods.Http.Post;
        request.ContentLength = postData.Length;
        request.ContentType = "application/x-www-form-urlencoded";
        request.KeepAlive = false; //also tried true as well

        StreamWriter writer = new StreamWriter(request.GetRequestStream());
        writer.Write(postData);
        writer.Close();
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader reader = new StreamReader(response.GetResponseStream());
        String responseString = reader.ReadToEnd();

        response.Close();

EXPERIMENT 3 !!!WORKING!!!

String ali = "datafromuser=<CC5Request><Name>Mert</Name><Password>123</Password><ClientId>1058</ClientId><IPAddress>213.456.654.456</IPAddress><Adress>asdsa</Adress><OrderId>123</OrderId><Type>Auth</Type>" +
"<Number>4522115422659661</Number><ExpiresAy>01</ExpiresAy><ExpiresYil>13</ExpiresYil><Cvv2Val>123</Cvv2Val><Total>10</Total><Taksit></Taksit><Kdv>18</Kdv><BankaID>1</BankaID>"+
"<TcKimlik>12345678912</TcKimlik></CC5Request>";

            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(ali);

            WebRequest req = WebRequest.Create("http://www.pay-pos.com/test.php");

            req.ContentType = "application/x-www-form-urlencoded"; 
            req.ContentLength = byteArray.Length;
            req.Method = "POST"; 

            Stream dataStream = req.GetRequestStream(); 
            dataStream.Write(byteArray, 0, byteArray.Length); 
            dataStream.Close();

            HttpWebResponse response = (HttpWebResponse)req.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            String responseString = reader.ReadToEnd();

            response.Close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:48:12+00:00Added an answer on June 7, 2026 at 10:48 am

    The first thing I see wrong is that you’re trying to use a query string to post the form data. Your “form data” should be like so:

     String ali = "datafromuser=<CC5Request><Name>Mert</Name><Password>123</Password><ClientId>xxxx</ClientId><IPAddress>213</IPAddress><Adress>asdsa</Adress>" +
                                "<OrderId>123</OrderId><Type>Auth</Type><Number>1234567891234567</Number><ExpiresAy>01</ExpiresAy><ExpiresYil>13</ExpiresYil><Cvv2Val>123</Cvv2Val>" +
                                "<Total>10</Total><Taksit></Taksit><Kdv>xx</Kdv><BankaID>1</BankaID><TcKimlik>12345678912</TcKimlik></CC5Request>";
    

    Next, you need to get the bytes[] from your form data.

    byte[] byteArray = Encoding.UTF8.GetBytes(ali);
    

    Set some headers:

    req.ContentType = "application/x-www-form-urlencoded"; 
    req.ContentLength = byteArray.Length;
    req.Method = "POST"; 
    

    Now write your data to the request stream.

    Stream dataStream = req.GetRequestStream(); 
    dataStream.Write(byteArray, 0, byteArray.Length); 
    dataStream.Close(); 
    

    Finally… get your response. Also note, anything that implements IDisposable should be wrapped in a using statement, i.e. Stream and WebResponse.

    Also note that the submit button is not part of your form post data. It’s possible the server is expecting it.

    Edit: Here’s a complete example from Microsoft that guides you step by step.

    http://msdn.microsoft.com/en-us/library/debx8sh9.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna make this rather simple to ask so I can hope for a
HI Guys. I wanna know how can I make a simple search using named
I have 2 question I wanna make Mysql table that have charset utf8 but
I wanna make an simple GUI application that work on at least Windows and
i've built my first wpf application, nothing fancy, but i wanna make it look
I will make upload my application today to my homepage and wanna to have
I wanna make the Mel-Frequency Cepstrum Algorithm but there are some things that I
i wanna make hotfile account checker inorder to start working ,i want to know
I wanna make a text editor but its different other text editors.It will get
I wanna make a init method which can understand these contstrutors. candy(name=foo, type=bar) or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.