Azure website Rest Api only accept GET, POST returns 403. Possibly CORS -


i encounter strange problem. have asp.net core webapi project running under azure app service (website). using dhc plug-in in chrome. service running aad.

i can request method fine (after login). however, when request post, got 403 response. looking around in log, can see this

2016-07-28t08:14:26 pid[x] verbose received request: post https://blahblah.azurewebsites.net/api/build/beep/

2016-07-28t08:14:26 pid[x] verbose found 'appserviceauthsession' cookie site 'blah.azurewebsites.net'. length: 856.

2016-07-28t08:14:26 pid[x] information sending response: 403.60 forbidden

2016-07-28t08:14:26 pid[x] warning cross-site request forgery detected user 'blah@blahblah.com' referer ''!

i using asp.net core 1.0. have cors enable in code (allorigin allheader), cors in azure website has entry '*', supposed accept every origin. log stream seems not hit website, in azure blocks request.

any help?

edit: successful method

2016-07-28t20:24:35 pid[22880] verbose received request: https://blah.azurewebsites.net/api/build/beep/

2016-07-28t20:24:35 pid[22880] verbose found 'appserviceauthsession' cookie site 'blah.azurewebsites.net'. length: 876.

2016-07-28t20:24:36 pid[22880] verbose authenticated blah@blah.com using 'session cookie' authentication.

looks javascript client being blocked authentication / authorization module's csrf protection, doesn't know cors configuration (it should - i'll this).

the simplest way work around add custom user-agent http header in client settings. 1 of things our built-in csrf protection looks whether client browser. pretty major browsers use "mozilla/..." user-agent string. change else make clear you're not browser , post request go through successfully.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -