asp.net mvc - Ajax call from LocalHost to same domain MVC Controller during using KendoDataSource -



asp.net mvc - Ajax call from LocalHost to same domain MVC Controller during using KendoDataSource -

i trying access info mvc controller on iis server located within domain. i'm getting error

"no 'access-control-allow-origin' header nowadays on requested resource. origin 'http://localhost:22205' hence not allowed access. "

here ajax call:

class="lang-js prettyprint-override">bindropdowndatasource: new kendo.data.datasource({ autobind: false, serverfiltering: true, datatype: "json", crossdomain: true, transport: { read: { cache: false, //url: "/logisticswebapp/requisitions/getbins", works if unremarked url: "https://www.mydomain.com/logisticswebapp/requisitions/getsites", xhrfields: { withcredentials: true }, data: function () { { sitecode: viewmodel.site.sitecode, shopcode: viewmodel.binshopblock.shopcode }; } } } })

here controller:

class="lang-cs prettyprint-override">public jsonresult getbins(string sitecode, string shopcode) { var lookups = new lookups(); var info = lookups.getbins(sitecode,shopcode); homecoming json(data, jsonrequestbehavior.allowget); }

i want able utilize application info layer need able develop against it.

if need particular method, might alter getbins action to:

public jsonresult getbins(string sitecode, string shopcode) { httpcontext.response.addheader("access-control-allow-origin", "*"); var lookups = new lookups(); var info = lookups.getbins(sitecode,shopcode); homecoming json(data, jsonrequestbehavior.allowget); }

edit

if need method not in controller must use:

httpcontext.current.response.addheader("access-control-allow-origin", "*");

ajax asp.net-mvc kendo-ui

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -