从代码隐藏调用ASP.NET Web API
发布时间:2020-05-22 21:33:06 所属栏目:asp.Net 来源:互联网
导读:我如何直接从代码隐藏调用ASP.NET Web API?还是应该调用我的 javascript函数,从代码隐藏中调用get JSON方法? 我通常有如下的东西: function createFile() { $.getJSON(api/file/createfile, function (data) { $(#Result).ap
|
我如何直接从代码隐藏调用ASP.NET Web API?还是应该调用我的 javascript函数,从代码隐藏中调用get JSON方法? 我通常有如下的东西: function createFile() {
$.getJSON("api/file/createfile",function (data) {
$("#Result").append('Success!');
});
}
任何指针赞赏. TIA. *我正在使用WebForms. 解决方法如果您必须调用Web服务本身,您可以尝试使用HttpClient as described by Henrik Neilsen.Updated HTTPClient Samples 一个基本的例子: // Create an HttpClient instance
HttpClient client = new HttpClient();
// Send a request asynchronously continue when complete
client.GetAsync(_address).ContinueWith(
(requestTask) =>
{
// Get HTTP response from completed task.
HttpResponseMessage response = requestTask.Result;
// Check that response was successful or throw exception
response.EnsureSuccessStatusCode();
// Read response asynchronously as JsonValue
response.Content.ReadAsAsync<JsonArray>().ContinueWith(
(readTask) =>
{
var result = readTask.Result
//Do something with the result
});
}); (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 使URL特定于(通过路由)
- asp.net-mvc – ASP.NET MVC View可以使用来自不同项目的模
- 以编程方式获取当前的ASP.NET信任级别
- Asp.net UserControl LoadControl问题
- asp.net-mvc – 如何在asp.net mvc中提交下拉列表
- ASP.NET MVC 5无法呈现jQuery UI CSS包
- asp.net – 在.aspx页面上显示图像的字节
- 在ASP.Net中防止SQL注入
- asp.net – ASMX服务在开发服务器上工作,部署到IIS 7.5时返
- asp.net-mvc – 如何使用Autofac将控制器的ModelState传递给
推荐文章
站长推荐
- ASP.NET捆绑和分类 – 包括用于生产捆绑包和未压
- 这个ASP.NET功能在哪里记录? %= string format
- .NET HttpSessionState案例不敏感
- asp.net-mvc – 单元测试中的ViewResult.ViewNam
- asp.net-mvc – ASP.NET MVC:访问集合中项目的M
- 身份更改GUID为int
- asp.net-mvc – 在自定义Html帮助器中访问模型对
- asp.net-mvc – ASP.NET MVC DropDown编辑器模板
- asp.net – ERR_CONNECTION_RESET:上传大文件时
- asp.net – Jquery datepicker:验证日期mm/dd/y
热点阅读
