如何调用ASP.NET web api

编程入门 行业动态 更新时间:2024-10-28 12:29:38
本文介绍了如何调用ASP.NET web api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好朋友, 我创建了网站,我想将Auth0(第三方)整合到我的应用程序中。问题是我在asp中创建了一个web api和我当请求更改密码时,想要在auth0内调用api。 有没有人知道这一点。请帮助我。 我尝试过: 1)$。ajax({ url:'http:/ / localhost:2615 / api / data / userdata / updatepass', 方法:'POST', 数据:{ email:email , Motdepasse:newPassword } })。然后(函数(数据){ 返回回调(数据); },function(){ 返回回调(到达服务器端点时出错); }); 2) var newName ='John Smith', xhr = new XMLHttpRequest(); xhr.open('POST','http:// localhost:2615 / api / data / userdata / updatepass'); xhr。 setRequestHeader('Content-Type','application / x-www-form-urlencoded'); xhr.onload = function(){ if(xhr.status === 200&& xhr.responseText!== newName){ alert('出错了。名字现在是'+ xhr.responseText); } 否则(xhr.status!== 200){ alert('请求失败。'+ xhr.status的返回状态); } }; xhr.send(encodeURI('name ='+ newName)); 上面的操作我试过但没有解决方案。

Hello friends, I had created website and i want to integrate Auth0 (third party) into my application.The problem is that i had created one web api in asp and i want to call api inside auth0 when request goes to change password. Is there any one who knows that very well.Please help me. What I have tried: 1)$.ajax({ url: 'localhost:2615/api/data/userdata/updatepass', method: 'POST', data: { email:email, Motdepasse:newPassword } }).then(function(data) { return callback(data); }, function() { return callback("Error reaching server endpoint"); }); 2) var newName = 'John Smith', xhr = new XMLHttpRequest(); xhr.open('POST', 'localhost:2615/api/data/userdata/updatepass'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function() { if (xhr.status === 200 && xhr.responseText !== newName) { alert('Something went wrong. Name is now ' + xhr.responseText); } else if (xhr.status !== 200) { alert('Request failed. Returned status of ' + xhr.status); } }; xhr.send(encodeURI('name=' + newName)); Above opsition i had tried but no solution.

推荐答案

.ajax({ url:'http:// localhost:2615 / api / data / userdata / updatepass', 方法:'POST', 数据:{ 电子邮件:电子邮件, Motdepasse:newPassword } })。然后(函数(数据){ 返回回调(数据); },函数(){ 返回回调(到达服务器端点时出错); }); 2) var newName ='Jo史密斯', xhr =新的XMLHttpRequest(); xhr.open('POST','http:// localhost: 2615 / api / data / userdata / updatepass'); xhr.setRequestHeader('Content-Type','application / x-www-form-urlencoded'); xhr.onload = function(){ if(xhr.status === 200&& xhr.responseText!== newName){ alert('出错了。名字现在是'+ xhr.responseText); } 否则(xhr.status!== 200){ alert('请求失败。'+ xhr.status的返回状态); } }; xhr.send(encodeURI('name ='+ newName)); 上面的操作我试过但没有解决方案。 .ajax({ url: 'localhost:2615/api/data/userdata/updatepass', method: 'POST', data: { email:email, Motdepasse:newPassword } }).then(function(data) { return callback(data); }, function() { return callback("Error reaching server endpoint"); }); 2) var newName = 'John Smith', xhr = new XMLHttpRequest(); xhr.open('POST', 'localhost:2615/api/data/userdata/updatepass'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function() { if (xhr.status === 200 && xhr.responseText !== newName) { alert('Something went wrong. Name is now ' + xhr.responseText); } else if (xhr.status !== 200) { alert('Request failed. Returned status of ' + xhr.status); } }; xhr.send(encodeURI('name=' + newName)); Above opsition i had tried but no solution.

})。then(function(data){应该由Success替换:function(data) }).then(function(data){ should be replace by Success: function(data) Correct format of

的正确格式

ajax如下: ajax is below:

更多推荐

如何调用ASP.NET web api

本文发布于:2023-10-29 13:29:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539818.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   ASP   api   web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!