Azure,应用程序服务;系统找不到指定的文件";
在Azure应用程序服务中拥有应用程序。一个.NETWeb项目 运行线路:Azure,应用程序服务;系统找不到指定的文件";,azure,azure-web-app-service,Azure,Azure Web App Service,在Azure应用程序服务中拥有应用程序。一个.NETWeb项目 运行线路: System.IO.File.ReadAllText("D:\home\site\wwwroot\Prod-Enterprise-Test-6-26-2016-credentials.publishsettings") 将抛出异常 系统找不到指定的文件 你可以看到文件在那里,相信我,它没有拼写错误,在本地它工作正常,部署时失败 您提到的代码需要更改如下: System.IO.File.ReadAllText(@"D:\
System.IO.File.ReadAllText("D:\home\site\wwwroot\Prod-Enterprise-Test-6-26-2016-credentials.publishsettings")
将抛出异常
系统找不到指定的文件
你可以看到文件在那里,相信我,它没有拼写错误,在本地它工作正常,部署时失败
您提到的代码需要更改如下:
System.IO.File.ReadAllText(@"D:\home\site\wwwroot\Prod-Enterprise-Test-6-26-2016-credentials.publishsettings")
你提到会抛出未发现异常,这很奇怪。如果文件存在,代码应该在azure网站中工作
系统找不到指定的文件
似乎期望是由其他代码引起的。我们也可以,我们可以得到更多关于异常的详细信息
我们还可以添加一个示例测试aspx页面来测试它。以下是我的测试步骤
1.创建.net Web项目和index.aspx页面
2.将代码添加到index.aspx.CS文件和index.aspx文件中
protected void Page_Load(object sender, EventArgs e)
{
var file= System.IO.File.ReadAllText(@"D:\home\site\wwwroot\Prod-Enterprise-Test-6-26-2016-credentials.publishsettings");
Label1.Text = file;
}
index.aspx
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
从浏览器访问索引页并检查其是否正常工作
问题出在代码的另一个位置。
发布的代码工作正常。这无助于您是否尝试远程调试WebApp?我无法远程调试,它是Azure sdk的2.2版,存在一些错误。不过我可以写日志。如果可能的话,请尝试使用最新版本。