Javascript .net web应用程序在VS中运行,但在IIS中获取404,生成错误的URL

Javascript .net web应用程序在VS中运行,但在IIS中获取404,生成错误的URL,javascript,jquery,asp.net-mvc,Javascript,Jquery,Asp.net Mvc,我有一个名为Facility的.net 4.6.2 MVC应用程序,它在Visual Studio中运行良好,但在IIS中失败。在“文档就绪”状态下,浏览器运行一系列功能,如下所示: function getInspectionEvents() { $.get("/Inspection/GetInspectionEvents", function (data) { model.inspection.removeAll(); for (var i = 0;

我有一个名为Facility的.net 4.6.2 MVC应用程序,它在Visual Studio中运行良好,但在IIS中失败。在“文档就绪”状态下,浏览器运行一系列功能,如下所示:

function getInspectionEvents() {
    $.get("/Inspection/GetInspectionEvents", function (data) {
        model.inspection.removeAll();
        for (var i = 0; i < data.length; i++) {
            model.inspection.push(data[i]);
        }
    });
}

但这不起作用。

如果您当前处于http中,由于同源策略,您无法向
https
页面发出AJAX请求

主机、端口和方案(协议)必须相同,AJAX请求才能工作

如果未提出跨域请求,您可以尝试以下操作:

$.ajax({
    type: "GET", 
    url: "https://(server)/Facility/Inspection/GetInspectionEvents",
    success: function(data){
        // --- your code here
             }
});
否则,在目标域上实现以允许此特定请求

$.ajax({
    type: "GET", 
    url: "https://(server)/Facility/Inspection/GetInspectionEvents",
    success: function(data){
        // --- your code here
             }
});