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

  • Home
  • SEARCH
  • 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 8257085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:04:54+00:00 2026-06-08T02:04:54+00:00

Using Visual Studio 2010 and .NET framework 4.0 I have built a simple HelloWorld

  • 0

Using Visual Studio 2010 and .NET framework 4.0 I have built a simple HelloWorld WCF service that is AJAX enabled based on the sample here: http://msdn.microsoft.com/en-us/library/bb924552.asp

However I need to pass a large amount of data to the service so I added a text area and another button to do that. Unfortunately I get a 400 error (bad request) from the server when I post more than a few hundred lines of text.

HelloWorldService.svc:

<%@ ServiceHost Language="VB" Debug="true" Service="HelloWorldAjaxWCFServiceWebApp.HelloWorldService"
CodeBehind="HelloWorldService.svc.vb" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>

HelloWorldService.svc.vb:

Imports System.ServiceModel
Imports System.ServiceModel.Activation
Imports System.ServiceModel.Web

<ServiceContract(Namespace:="HelloWorldAjaxWCFServiceWebApp")>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Public Class HelloWorldService

    <OperationContract()>
    Public Function Echo(ByVal data As String) As String
        Return data
    End Function

    <OperationContract()>
    <WebInvoke(Method:="POST")>
    Public Function HelloWorld(ByVal Name As String) As String
        If Name.Length > 100 Then
            Return "Hello " & Name.Substring(0, 100)
        Else
            Return "Hello " & Name
        End If
    End Function

End Class

HelloWorld.aspx:

<%@ Page Language="VB" AutoEventWireup="true" CodeBehind="HelloWorld.aspx.vb" Inherits="HelloWorldAjaxWCFServiceWebApp.HelloWorld" %>

<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="HelloWorldService.svc" />
        </Services>
    </asp:ScriptManager>
    </form>
    <p>
        <input id="txtHello" type="text" value="Your Name Here" />
        <input id="btnHello" type="button" value="Hello World" onclick="return btnHello_onclick()" /></p>
    <p>
        <textarea id="txtLong" name="S1" rows="50" cols="50"></textarea>
        <input id="btnLong" type="button" value="Send Long Text"
            onclick="return btnLong_onclick()" /></p>
    <div id="Results"></div>
    <script language="javascript" type="text/javascript">
        // <!CDATA[

        function btnHello_onclick() {
            var txt = document.getElementById('txtHello');
            var service = new HelloWorldAjaxWCFServiceWebApp.HelloWorldService();
            //service.Echo('echo', onSuccess, FailedCallback, null);
            service.HelloWorld(txt.value, onSuccess, FailedCallback, null);
        }

        function btnLong_onclick() {
            var txt = document.getElementById('txtLong');
            var service = new HelloWorldAjaxWCFServiceWebApp.HelloWorldService();
            //service.Echo('echo', onSuccess, FailedCallback, null);
            service.HelloWorld(txt.value, onSuccess, FailedCallback, null);
        }

        function onSuccess(result) {
            alert(result);
        }

        // This is the failed callback function.
        function FailedCallback(error) {
            var stackTrace = error.get_stackTrace();
            var message = error.get_message();
            var statusCode = error.get_statusCode();
            var exceptionType = error.get_exceptionType();
            var timedout = error.get_timedOut();

            // Display the error.    
            var results = document.getElementById("Results");
            results.innerHTML =
                "Stack Trace: " + stackTrace + "<br/>" +
                "Service Error: " + message + "<br/>" +
                "Status Code: " + statusCode + "<br/>" +
                "Exception Type: " + exceptionType + "<br/>" +
                "Timedout: " + timedout;
        }

        // ]]>
    </script>
</body>
</html>

I’ve removed the entire entry from the web config file and it works as described above. I’ve been having a lot of trouble with the web.config file and trying out different settings suggested on the web. some have no apparent effect, while others cause a ‘service is undefined’ error in the Javascript, so getting the config ‘just right’ is proving to be a problem.

How can I configure the service to accept large amounts of data? Secondly, for provided answers, what effect does a particular setting actually have in the real world?

Note that jquery is not an option.

Thanks

  • 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-08T02:04:56+00:00Added an answer on June 8, 2026 at 2:04 am

    I eventually solved this problem by redoing the config from scratch.

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

Sidebar

Related Questions

I have a Visual Studio 2010 project that is targeted to .NET Framework 3.5.
I have created an OData/WCF service using Visual Studio 2010 on Windows XP SP3
I'm using Visual Studio 2010 RTM with .NET/Entity Framework 4 RTM with a model
I have a asp.net website with c# code behind and using visual studio 2010.
To begin with: Using Entity Framework v4.0. ASP.NET MVC 2.0. Visual Studio 2010. I
My scenario I'm using Visual Studio 2010 with Entity Framework 4.1 I have a
I have a Windows service written in C# using Visual Studio 2010 and targeting
Using Visual Studio 2010 .Net Framework 4 C# Linq to Entities Issue I would
In Visual Studio 2010, my solution was using .NET 4.2 (Entity Framework June 2011
Using ASP.net and c# using visual studio 2010 Hi all, I hope some one

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.