asp.net mvc 4 - Web Api hosted on another port on IIS is not accessible -


i have 2 separate projects

  1. mvc web app
  2. mvc web api have published both on iis 7.5

my web app hosted on 7172 port , web api hosted on 7171 port

strangely iam not able call jquery.ajax() web app (7172) web api (7171) port. gives me 405 method not found error code.

but if write same jquery.ajax() in web api project (7171) , call web api method work fine , returns data.

i want call web api web app.

any suggestion appreciated.

thanks in advance.

this has same origin policy. default, can't execute ajax call domain (both on name, port , protocol).

if want enable should use cross-origin resource sharing (cors). cors can used web api installing (prerelase) nuget package: microsoft asp.net web api cross-origin support

this package allows configure domains can call service. can find walk trough here enabling cross-origin requests in asp.net web api. in essence comes down adding attributes controllers this:

 [enablecors(origins: "http://myclient.azurewebsites.net", headers: "*", methods: "*")] 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -