gpt4 book ai didi

c# - Azure Web App 引发 HTTP 错误 500.0 - 内部服务器错误 由于发生内部服务器错误,无法显示页面

转载 作者:行者123 更新时间:2023-12-03 06:54:20 27 4
gpt4 key购买 nike

我确实有一个基于 .NET Framework 应用程序的 C# ASP.NET Web API 在本地计算机上运行得非常好。但是,当我将其部署到 Azure Web App Service 并尝试访问其中一个端点时,出现错误:

The error message as received in the Application Log Stream我不明白的是错误中的文件夹 \api\print 来自哪里?我的端点正在做两件事:

  1. 创建 PDF 文件。这工作正常,因为我可以在 wwwroot\app_data 文件夹中看到创建的文件
  2. 将创建的 PDF 文件上传到 Google 云端硬盘。这就是代码失败的地方。我怀疑是因为该应用程序无法打开该文件。

下面是上述操作的代码:

    public GoogleDrivePDFFile CreateTicket()
{
//directory for created files as per stakeoverflow question https://stackoverflow.com/questions/1268738.
string tickets_path = HostingEnvironment.MapPath("~/App_Data/");

//current date and time
var current_date_time = DateTime.UtcNow;

string google_file_name = string.Concat(
current_date_time.Year,
current_date_time.Month,
current_date_time.Day,
current_date_time.Hour,
current_date_time.Minute,
current_date_time.Second,
"_", "XXXX",
".pdf"
); //the filename to use for the new created file

//full path for the new file in the filesytem
string filName = Path.Combine(tickets_path, google_file_name);

//file is being created okay in the filesystem. I can see it in Azure app file system.
PdfFormatProvider provider = new PdfFormatProvider();
using (Stream output = File.Open(filName, FileMode.CreateNew))
{
provider.Export(document, output);
}

GoogleUploads googleUploads = new GoogleUploads();

//It is failing here.....
var returned_file = googleUploads.UploadTicket(google_file_name, filName, requiredDocument);

/*
* I have tested the endpoint with the below and this works fine.
*
var working_example = new GoogleDrivePDFFile();
working_example.DocumentId = "Document ID .... okay";
working_example.DownloadLink = "Download Link .... okay";
working_example.WebViewLink = "Web View Link .... okay";

return working_example;
*/

return returned_file;
}

我不知道我做错了什么。

最佳答案

就我而言,我的 Google 安全 key 文件未上传到 Azure Web 应用程序文件系统。这就是我的代码无法工作的原因。我上传了 key 文件并且我的应用程序运行了。

关于c# - Azure Web App 引发 HTTP 错误 500.0 - 内部服务器错误 由于发生内部服务器错误,无法显示页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73214441/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com