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 8872719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:17:21+00:00 2026-06-14T18:17:21+00:00

I have a problem. I want to do a post action and I’m doing

  • 0

I have a problem. I want to do a post action and I’m doing it like this:

string post_data = string.Format("taskId={0}&inputId={1}&value={2}", taskId, inputId, "101");

string uri = "http://localhost:60837/Default.aspx";
// Create a request using a URL that can receive a post. 
        WebRequest request = WebRequest.Create(uri);
        // Set the Method property of the request to POST.
        request.Method = "POST";
        // Create POST data and convert it to a byte array
        var byteArray = Encoding.UTF8.GetBytes(post_data);
        // Set the ContentType property of the WebRequest.
        request.ContentType = "application/x-www-form-urlencoded";
        // Set the ContentLength property of the WebRequest.
        request.ContentLength = byteArray.Length;
        // Get the request stream.
        Stream dataStream = request.GetRequestStream();
        // Write the data to the request stream.
        dataStream.Write(byteArray, 0, byteArray.Length);
        // Close the Stream object.
        dataStream.Close();
        // Get the response.
        WebResponse response = request.GetResponse();
        // Display the status.
        Console.WriteLine(((HttpWebResponse)response).StatusDescription);
        // Get the stream containing content returned by the server.
        dataStream = response.GetResponseStream();
        // Open the stream using a StreamReader for easy access.
        StreamReader reader = new StreamReader(dataStream);
        // Read the content.
        string responseFromServer = reader.ReadToEnd ();
        // Display the content.
        Console.WriteLine(responseFromServer);
        // Clean up the streams.
        reader.Close();
        dataStream.Close();
        response.Close();

This is my code-behing of my default.aspx:

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(Caller.Process(Request.RawUrl, Request.QueryString, Request.UserHostAddress));
    }
}

And my Process method look like this:
static readonly string
//paramDefinition = “definition”,
paramTaskId = “taskId”,
paramInputId = “inputId”,
paramValue = “value”;

    static public string Process(string query, NameValueCollection collection, string ip)
    {
        StringBuilder result = new StringBuilder();

        Func<string, bool> check = str =>
        {
            if (!collection.AllKeys.Contains(str))
            {
                result.AppendLine(string.Format("No {0} parameter. ", str));
                return false;
            }
            return true;
        };
        if (check(paramTaskId) && check(paramInputId) && check(paramValue))
        {
            result.Append("OK");
            Execute(query, collection, ip);
        }
        else
        {
            WriteLog(result.ToString(), query, ip);
        }

        return result.ToString();
    }

The problem is I get no parameters on my Deafault.aspx. When I’m doing it in my browser everything is ok. Do you know what can be a problem? Thanks in advance;)

  • 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-14T18:17:24+00:00Added an answer on June 14, 2026 at 6:17 pm

    Using the browser method, you are passing the variables by GET (i.e., using parameters passed as part of the url). Using the code, you are passing by POST. Those are two different things, and they are handled differently when processing on the server side.

    When you reference the variables in the code for Default.aspx, you are using Request.QueryString which looks specifically for parameters passed via GET, or in the url. To retrieve the variables passed via POST, you need to use Request.Form["varName"].

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

Sidebar

Related Questions

i have a php code like this <html> <body> <center> <FORM action= method=post> <input
I have this problem: I want to generate a new source code file from
I have a problem when I want to sending data using byte format in
I have a problem similer to this post I have tried this RewriteCond %{HTTP_HOST}
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
I have this problem with Zend Framework wherein I want my headLink and headScript
I am using GWT/JAVA for development. I have following problem: I want to remove
I have a problem and I want to implement the MVC pattern to my
I have problem, when I want add Node to my GUI from other Thread.
I have problem with fancybox. I want to write a function that will run

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.