大佬教程收集整理的这篇文章主要介绍了IIS 10 AJAX 不适用于 dotnet core 5 MVC,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在编写一个 asp dot net core MVC 应用程序。这里我使用的是 GET AJAX 调用。 当我从 Visual studio 运行我的应用程序时,它可以正常工作。但是在部署到我的本地 IIS 10 服务器后,我的 AJAX 调用给了我以下错误消息。
有什么帮助或建议为什么在 IIS 上会发生这种情况?
GET http://mycrt.geotab/GitLab/GetRackStatus 500 (Internal Server Error) jquery.Js:10099
这是我的 AJAX 调用
$('#rackInfo').click(function () {
var url = 'GitLab/GetRackStatus'; //http://mycrt.geotab/GitLab/GetRackStatus URL also returns same error
$.blockUI();
$.AJAX({
url: url,type: "GET",success: function (responseHTML) {
$('#rackInfoResults').@R_616_9363@ceWith(responseHTML);
$('#rackInfoResultsError').hIDe();
bindEventsOnRacks();
$.unblockUI();
},error: function (responseHTML) {
$('#rackInfoResults').hIDe();
$('#rackInfoResultsError').show();
$.unblockUI();
}
});
});
这是我的控制器
public async Task<IActionResult> GetRackStatus()
{
//Controller code
return PartialVIEw("_RackStatusPartialVIEw");
}
{
"IISSetTings": {
"windowsAuthentication": false,"anonymousAuthentication": true,"IISExpress": {
"applicationUrl": "http://localhost:53400","sslPort": 44339
}
},"profiles": {
"IIS Express": {
"commandname": "IISExpress","launchbrowser": true,"environmentvariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},"MyCRT": {
"commandname": "Project","environmentvariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},"dotnetRunmessages": "true","applicationUrl": "https://localhost:5001;http://localhost:5000"
},"Docker": {
"commandname": "Docker","launchUrl": "{scheR_524_11845@E}://{serviceHost}:{servicePort}","publishAllPorts": true,"useSSL": true
}
}
}
注意:我在 AJAX 中尝试使用以下 URL,结果出现以下错误
http://localhost/GitLab/GetRackStatus
Access to XMLhttprequest at 'http://localhost/GitLab/GetRackStatus' from origin 'http://mycrt.geotab' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Failed to load resource: net::ERR_Failed
这是我的 IIS 配置文件
这可能发生在几个问题上。
以上是大佬教程为你收集整理的IIS 10 AJAX 不适用于 dotnet core 5 MVC全部内容,希望文章能够帮你解决IIS 10 AJAX 不适用于 dotnet core 5 MVC所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。