javascript - Trouble passing custom headers in a CORS GET request using jquery -


i wrote web api need accessed outside of app domain. have cors enabled , i'm able make api call outside application domain. i'm trying pass in custom http headers part of request i'm not able working

i searched in web working unable to. i'm trying pass in 2 parameters appid custom header on request web api call using jquery $.ajax.

            url: "http://localhost:38994/api/search/getsearchresults",                             type: 'get',             datatype: 'json',             headers: { 'appid': '234' },             data: { param1: 1, param2: { search_by_param: 'xyz', category: 'null'}},                                                 success: function (result) {                                                         alert(result);                                 }        , error: function (err) { alert(err); } 

i tried use beforesend add headers well. regardless use 'headers' or beforesend add headers, see custom header names added 'access-control-request-headers' as

access-control-request-headers: accept, appid 

i tried use jsonp using webapicontrib.formatting.jsonp nuget. after add reference, project goes toss. see 'dll version mismatch on system.web.http.dll between ver 4.0 , 5.0'

can advice me on how pass custom http headers in cors? note when try pass custom http headers within application, works


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -