1
您好我已經創建了一個Windows通用應用程序,其中我使用託管在我的計算機IP地址上的API。當我運行應用程序,無論是從VS15還是從應用程序包,它都可以正常工作。但只要我在使用應用程序包的另一臺機器上運行此應用程序,它不起作用。 同樣,如果我在另一臺機器的IP地址上託管相同的API,它將停止在我的機器上工作。 即使在這兩種情況下,我都可以通過瀏覽器中的URL路徑訪問數據。 但在手機上運行應用程序包效果很好。在Windows 10通用應用程序中託管api問題
SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd.
它顯示此錯誤。
這裏是我的ajax調用示例:
var ajaxRequest = $.ajax({
url: apiAddress + "Conversation/Welcome"
});
ajaxRequest.done(function (response, textStatus) {
if (textStatus == 'success') {
//success
} else {
//fail
}
});
我webapiconfig.cs
public static void Register(HttpConfiguration config)
{
// Web API routes, configuration and services
config.EnableCors();
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
}
我已經把[EnableCors(origins: "*", headers: "*", methods: "*")]
類以上。
請幫幫我。我做錯了什麼?
Manifest中不允許私人網絡訪問。只要我允許它工作正常。 – Sonali