我有以下API可以验证mySQL表中的电子邮件地址。
。 。
[EnableCors(origins: "http://www.demo.MainSite.com, always", headers: "*", methods: "*", SupportsCredentials =true)]
public class StarSystemController : ApiController
{
DataConnection oDataConnection { get; set; }
[AllowAnonymous]
[HttpPost]
[Route("api/Starsystem/UserExists")]
public string IsUserNameExists(W_Email Email)
{
CreateDataConnection();
bool result = oDataConnection.IsUserNameExists(Email);
string output = JsonConvert.SerializeObject(result);
return output;
}
API在Postman和Swagger中工作正常。但是,当我在Angular代码中调用此代码时,会出现以下错误。
Failed to load resource: net::ERR_CONNECTION_RESET
main.53cb435a591be8fbffcf.js:1错误
t {headers: n, status: 0, statusText: "Unknown Error", url: null, ok: false, …}
error: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: "error", …}
headers: n {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)}
message: "Http failure response for (unknown url): 0 Unknown Error"
name: "HttpErrorResponse"
ok: false
status: 0
statusText: "Unknown Error"
url: null
__proto__:
constructor: ƒ t(t)
__proto__: Object
我无法弄清楚它的确切来源。任何帮助表示赞赏。
我在ASP.net后端中遵循以下站点进行CORS设置。 MVC web api: No 'Access-Control-Allow-Origin' header is present on the requested resource