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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:12:06+00:00 2026-05-24T04:12:06+00:00

If you run this code it will throw a WebException. The inner exception is

  • 0

If you run this code it will throw a WebException. The inner exception is “Content-Length or Chunked Encoding cannot be set for an operation that does not write data.” and I do not understand the nature of the problem. Can anyone cast light into this dark corner?

using System.Diagnostics;
using System.Net;
using System.Text;

namespace sandpit
{
  static class Program
  {
    static void Main()
    {
      string INITIAL_URI = "http://docs.live.net/SkyDocsService.svc";
      string SOAP = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><GetWebAccountInfoRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://schemas.microsoft.com/clouddocuments\"><BaseRequest><ClientAppId>SkyDrive Service Client</ClientAppId><Market>en-US</Market><SkyDocsServiceVersion>v1.0</SkyDocsServiceVersion></BaseRequest><GetReadWriteLibrariesOnly>false</GetReadWriteLibrariesOnly></GetWebAccountInfoRequest></s:Body></s:Envelope>";
      using (WebClient wc = new WebClient())
      {
        wc.Encoding = Encoding.UTF8;
        wc.Headers["SOAPAction"] = "GetWebAccountInfo";
        wc.Headers["Accept-Language"] = "en-US";
        wc.Headers["Accept"] = "text/xml";
        wc.Headers["Content-Type"] = "text/xml; charset=utf-8";
        string response = wc.UploadString(INITIAL_URI, SOAP);
        Debug.WriteLine(response);
      }
    }
  }
}
  • 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-05-24T04:12:07+00:00Added an answer on May 24, 2026 at 4:12 am

    The problem is redirection by the webserver.

    Unfortunately you have to subclass WebClient to fix this. This is harder than it looks because Silverlight (any flavour) doesn’t like this and throws an inheritance related exception until you guess that you need to override the ctor and attribute it as SecurityCritical.

    public class WebClient2 : WebClient
    {
      [SecurityCritical]
      public WebClient2() : base() { }  
      protected override WebRequest GetWebRequest(System.Uri address)
      {
        var wr = base.GetWebRequest(address);
        if (wr is HttpWebRequest)
          (wr as HttpWebRequest).AllowAutoRedirect = false;
        return wr;
      }
    }
    

    If you want to go further you could surface an AllowAutoRedirect property on WebClient2 and hook it all up.

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

Sidebar

Related Questions

We have a chunk of code something like this // semi-pseudo code def result
I have this code copied from C# 4.0 in a nutshell that uses Attribute/Reflection
The following code works fine in Scala 2.8 but not in 2.9.0.1 (copy and
I'm scratching my head on this one. I'm trying to use boost::variant to store
I am writing client code in Scala that needs to interface with a framework
I am running into an extremely strange behavior in Groovy. When I throw an
There are similar posts here. I just want to clarify something. I implemented this
I am making a custom ActiveForm method, but it requires the model to have
I was wondering what everyone's opinion was with regard to pre-checking foreign key look

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.