Unity3D 4.x and System.nets WebClient

Hey developers / unitos,

I’m trying to use the WebClient together with Unity3D
Everything works fine in the editor (I can post without any problems) however when I put it online on a website it stops working.

does anyone know what the problem could be?

Is it now allowed to use System.nets Webclient?

Thanks in advance!

using UnityEngine;
using Facebook.MiniJSON;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.IO;

public class WebClient_TimeoutWebClient : WebClient
{
	public int Timeout { get; set; }
	
	public WebClient_TimeoutWebClient()
	{
		Timeout = 60000;
	}
	
	public WebClient_TimeoutWebClient(int timeout)
	{
		Timeout = timeout;
	}
	
	protected override WebRequest GetWebRequest(Uri address)
	{
		WebRequest request = base.GetWebRequest(address);
		request.Timeout = Timeout;
		return request;
	}
}

public class WebService
{
	public static string status = null;

	public static string DoPostRequest(string page, System.Collections.Specialized.NameValueCollection reqparm)
	{
		status = "doPostRequest called \n";
		string[] keys = reqparm.AllKeys;
		foreach(string key in keys)
		{
			status += "paramater: " + key + " (" + reqparm[key] + ") \n";
		}

		// never send Expect: in header
		System.Net.ServicePointManager.Expect100Continue = false;
		
		using (WebClient_TimeoutWebClient client = new WebClient_TimeoutWebClient())
		{
			// The problem is somewhere here in the next few lines.
			client.Timeout = 10000;
			if(reqparm == null)
				reqparm = new System.Collections.Specialized.NameValueCollection();
			byte[] responsebytes = client.UploadValues(page, "POST", reqparm);
			string responsebody = Encoding.UTF8.GetString(responsebytes);

			return responsebody;
		}
	}
	
	public static dynamic ParseDynamicJSON(string jsonData)
	{
		return Json.Deserialize (jsonData);
	}
}

I think WebClient is supported in the web player. What error/problem do you get?

Don’t get a error/problem (as far as I know).

However it does not upload any values when I post them with Webclients UploadValues(…) function.
As stated before, it does work when I call it from inside the Unity Editor.