ASP.Net Web应用程序在本地工作,但是发布到Azure应用程序服务后,所有Web请求都得到404

时间:2019-06-14 19:04:45

标签: asp.net azure

我创建了一个非常简单的ASP.NET Web应用程序,当我在Visual Studio中本地运行它时,它可以工作。当我通过Visual Studio发布HTML和JS功能时,按预期进行,但是当我尝试发出请求时,它只会返回子HTTP状态为0的404。我在Azure门户的日志中找到了失败的请求,但它提供了我没有任何帮助(也许我不知道我应该寻找什么)。

JS请求:

var mainURL = "api/values";
function getData() {
    $.ajax(mainURL + "",
        {
            method: "GET",
            success: getFeedback,
            error: error
        });
}

在ValuesController.cs中获取端点:

[HttpGet]
public IEnumerable<string> Get()
{
     return new String[] { "String 1", "String 2"};
}

在这里,我从每个失败请求的日志中得到的信息:

timestamp [UTC]:  2019-06-14T18:37:28.4905616Z
id:-  |t6BRs.GIk+K.5d5a779d_
name:-  GET Values/Get
url:-  https://snowcrew.azurewebsites.net/api/values
success:-  False
resultCode:-  404
duration:-  26,036.3695
performanceBucket:-  15sec-30sec
itemType:-  request
customDimensions:-  {"_MS.ProcessedByMetricExtractors":"(Name:'Requests',Ver:'1.1')","AspNetCoreEnvironment":"Production"}
operation_Name:-  GET Values/Get
operation_Id:-  t6BRs
operation_ParentId:-  |t6BRs.GIk+K
session_Id:-  Weaja
user_Id:-  /2aXn
application_Version:-  1.0.0.0
client_Type:-  PC
client_IP:-  0.0.0.0
client_City:-  MyCity
client_StateOrProvince:-  MyState
client_CountryOrRegion:-  United States
cloud_RoleName:-  snowcrew
cloud_RoleInstance:-  RD0004FFDD7879
appId:-  9114c348-64a5-4490-8c37-7c469252ba2a
appName:-  SnowCrew
iKey:-  55a1c3de-a678-49af-9fcb-9212758047fb
sdkVersion:-  ar_aspnet5c:2.6.1
itemId:-  97b165e2-8ed3-11e9-905b-5feb1a1b3fb1
itemCount:-  1

0 个答案:

没有答案