欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Why ngx-uploader doesn't like to cooperate with .net core 2.x?

程序员文章站 2023-12-26 21:43:57
The POST action seems to have no effect on the .net core controller. If you put [IgnoreAntiforgeryToken] attribute on the server controller method, it ......

the post action seems to have no effect on the .net core controller.

if you put [ignoreantiforgerytoken] attribute on the server controller method, it works. but dont' leave it like that exposing vulnerability.

turns out, angular uses a particular header name "x-xsrf-token" to store token for the server to accept: 

the following client code snippet in the angular 6 component works. it's just part of . only to note the headers line.

const event: uploadinput = {
type: 'uploadall',
url: this.upload_api_url + '?guid=' + this.guid,
method: 'post',
headers: {'x-xsrf-token': this._cookieservice.get("xsrf-token")},
withcredentials: true,
data: { foo: 'bar' }
};

_cookieservice is an injected service using . you may use any cookie tool.

上一篇:

下一篇: