在ASP.NET好康HTTP API请求 [英] Http Api request in ASP.NET WebPage

查看:87
本文介绍了在ASP.NET好康HTTP API请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要使用ASP.NET C#的请求。这里是HTTP API的文档,但我很困惑着如何发送请求。你可以帮我做域名检查方法,因为我想,但没有得到它的工作。

I want to make a request using ASP.NET C#. Here is the Documentation of the HTTP API but I am confused with how to send the request. Can you please help me do the Domain Check method, as I am trying but not getting it to work.

var auth-id = "123456";
var auth-key= "somerandomstring";
var auth-pass = "password";
var url = ("https://test.httpapi.com/api/domains/available.json?auth-userid=" + auth_id + &api-key=" + auth_key + "&domain-name=" + domain_name + "&tlds=" + tlds);

HTML表单我已经创建了像:

HTML Form I have Created is like:

<form action="" method="get">
    <input type="text" name="domainName" required />
    <input type="submit" name="Submit" value="Submit" />
</form>

这之后,我提交 IsPost 函数被调用。现在,我怎么传递值?

After this I submit the IsPost function is invoked. Now, how do I pass values?

现在我怎么能使用这些参数,以获得JSON结果。我已经安装的NuGet的JSON库。 ASP.NET网页是正在使用的技术。

Now how can I use these parameters to get the JSON result. I have installed the json library from nuget. ASP.NET Web Pages is the technology which is being used.

文档: http://cp.justfhost.com/kb/answer/764

我怎样才能做到这一点?

How can I do this?

推荐答案

创建一个Web客户机到值发送到指定网址

Create a WebClient to send the values to the specified Url

   var client = new WebClient();
   var stream  = client.OpenRead (url);
   var reader = new StreamReader (stream);
   string json = reader.ReadToEnd ();
   data.Close ();
   reader.Close ();
   // Deserialize json (supposing you are using package Newtonsoft.Json)
   var obj = JsonConvert.DeserializeObject(json);

请参阅Json.NET样品中 http://james.newtonking.com/ JSON /帮助/ index.html的与WebClient类中的 http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

See the samples of Json.NET in http://james.newtonking.com/json/help/index.html and the documentation of WebClient class in http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

这篇关于在ASP.NET好康HTTP API请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆