Tag: rsa

jQuery AJAXpost收到405错误(不允许HTTP动词POST)

我有一个ASP.NET webmethod的以下jQuerypost: $.ajax({ type: “POST”, url: “AjaxWebMethods.aspx/UpdNote”, contentType: “application/json; charset=utf-8”, data: “{‘ID’ : ‘” + id + “‘, ‘note’ : ‘” + note + “‘ }”, dataType: “json”, success: UpdNote_Success, error: AjaxError }); 并声明了Web方法: [System.Web.Services.WebMethod(enableSession: true)] public static int UpdNote(int ID, string note) { // business logic that eventually returns a number, but simplifying // […]

安全地从jquery调用我的web api

我有一个简单的问题,可能指出一个复杂的答案:( 我有一个web api工作正常。 但现在我想设置身份validation/授权。 我需要它在所有平台上工作,但主要来自jQuery。 当然,我不希望以明文forms在管道中发送我的用户名和密码,如下所示: function GetAllCategories() { var credentials = $.base64.encode(‘r3plica:mypassword’); var authType = “Basic ” + credentials; $.ajax({ url: “http://localhost:18904/api/Categories”, type: “GET”, beforeSend: function (xhr) { xhr.setRequestHeader(“Authorization”, authType); }, success: function (data) { alert(‘Success!’); }, error: function () { alert(‘error’); } }); } 所以我一直在寻找其他选择。 是使用3腿OAuth的唯一选择吗? 我希望只是将查询字符串键/值传递给我的api并让它处理所有内容,但我无法找到一步一步的过程。 一切似乎都很复杂。 那么,有谁知道我能做什么? 我已阅读负载并试图实现大量的东西。 我设法让这个工作: http : […]