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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:10:34+00:00 2026-06-12T16:10:34+00:00

When I try to post JSON string to client side, I have the error

  • 0

When I try to post JSON string to client side, I have the error below.

Uncaught Error: You're trying to decode an invalid JSON String: 

<!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>

</title></head>
<body>
    <form method="post" action="WebForm1.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZDU/UqTLS4JCyWg8lH2WKg+TKxlfMLv46f+TlE5HbZ5k" />
</div>

    <div>

    </div>
    </form>
</body>
</html>

It returns all HTML page. My server side code is like this:

var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:59145/My%20Application.app/webapp/index.html");
        httpWebRequest.ContentType = "application/json";
        httpWebRequest.Method = "POST";
        string json = "{ \"myresultlist\": [ {\"uname\": \"1\",\"pass\": \"anne\" }, { \"uname\": \"2\", \"pass\": \"jack\" }, {\"uname\": \"3\", \"pass\": \"Tom\" } ]}";


        httpWebRequest.ContentLength = json.Length;

        using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        {

            streamWriter.Write(json);
            streamWriter.Flush();
            streamWriter.Close();

        }

Anybody has any idea? How can I send only JSON string to client?

  • 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-12T16:10:36+00:00Added an answer on June 12, 2026 at 4:10 pm

    The solution is below.

    The reason for error is server side post operation.

    When I change the code with this block, i get the json string.

    Response.Expires = 0;
    Response.ContentType = "application/json";
            Response.Write("{ \"myresultlist\": [ {\"uname\": \"1\",\"pass\": \"anne\" }, { \"uname\": \"2\", \"pass\": \"jack\" }, {\"uname\": \"3\", \"pass\": \"Tom\" } ]}");
            Response.End();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HttpRequestValidationException occurs when I try post when txtBulletin contains any HTML, like Hello<br />World
I could try to post and explain the exact query I'm trying to run,
I have a POST controller action like: if (ModelState.IsValid) { try { //.. save
I'm trying to figure out how to POST JSON from Android by using HTTPClient.
I'm trying to contact a RESTful WCF POST web service from an android client
I am trying to use JSON and HTTP client to retrieve data from a
I have been trying to parse Json into A ListView but when i do
I have the following code on the client side for retrieving data from the
I'm using Apache HttpComponents Client to POST to a server that returns JSON. The
i try to post data by ajax , it gives me name value bu

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.