如何使用request.header获取令牌 [英] How to get token using request.header

查看:160
本文介绍了如何使用request.header获取令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在jquery ajax函数中我通过标题传递令牌和id,如下所示作为跨域请求

$ .ajax({

Hi,
In jquery ajax function I am passing token and id with header as below as a cross domain request
$.ajax({

error: function (xhr, status, error) { alert(error); },
                    beforeSend: setHeader
                });







function setHeader(xhr) {
            xhr.setRequestHeader('X-ProspectAppApiKey', '8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703');
        }





现在在服务端,我想获得标题'8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703使用



request.Headers.GetValues(Access-Control-Request-Method);



但是我只得到X-ProspectAppApiKey而不是8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703请帮忙。



谢谢



Now at service end I want to get header '8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703" using

request.Headers.GetValues("Access-Control-Request-Method");

but I am getting only X-ProspectAppApiKey not 8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703 with this please help .

Thanks

推荐答案

.ajax({

.ajax({
error: function (xhr, status, error) { alert(error); },
                    beforeSend: setHeader
                });







function setHeader(xhr) {
            xhr.setRequestHeader('X-ProspectAppApiKey', '8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703');
        }





现在在服务端,我想得到标题'8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703使用



request.Headers.GetValues(Access-Control-Request-Method);



但是我只得到X-ProspectAppApiKey而不是8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703请帮助。



谢谢



Now at service end I want to get header '8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703" using

request.Headers.GetValues("Access-Control-Request-Method");

but I am getting only X-ProspectAppApiKey not 8EJBD14I:f9a2ac88-6a76-48cf-vcvcvc-3f54bb830703 with this please help .

Thanks


这篇关于如何使用request.header获取令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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