传递凭据不工作凭据、工作

2023-09-11 00:57:47 作者:轻雾山林

我试图做一个JSON调用,传递的凭据。如果用户已经登录到使用SQL成员资格制度,我怎么能凭据传递没有得到这样的:

I am trying to make a json call, by passing the credentials. If the user is already logged into the system using Sql Membership, how can I pass the credentials without getting this:

下面是code调用web.api:

Here is the code that calls the web.api:

注:呼叫正在从跨域:即www.project.com - > api.project.com

NOTE: call is being made from cross domain: i.e. www.project.com -> api.project.com

var url = 'http://api.project.com/LookUps/uploadtypes?callback=?';

$.ajax({
    type: 'GET',
    url: url,
    async: true,
    xhrFields: {
        withCredentials: true
    },
    jsonpCallback: 'handler',
    contentType: "application/javascript",
    dataType: 'jsonp',
    success: function (json, textStatus, jqxhr) { console.log(jqxhr.responseText); },
    error: function (json, textStatus, jqxhr) { console.log(jqxhr.responseText); }
 });

编辑:

我仍然得到了登录时的身份验证被禁用。是否有另一个地方为窗口的身份验证设置?

I still get the login when authentication is disabled. Is there another place for the window authentication setting?

推荐答案

要prevent这个弹出,你必须将你的URL更改为以下。

To prevent this popup you have to change your URL to following.

VAR URL ='的http://用户名:password@api.project ?.COM /查找/ uploadtypes回调= ';

var url = 'http://username:password@api.project.com/LookUps/uploadtypes?callback=?';

替换用户名 - 与实际的用户名 和密码的实际密码。

replace username - with actual username and password with actual password.

 
精彩推荐
图片推荐