【发布时间】:2018-09-29 10:59:09
【问题描述】:
我在 ASP.NET Core WebApi 项目中使用 Google Drive API v3,但它不适用于 IIS。 它可以通过 Kestrel 服务器上的 Visual Studio 2017 在本地正常工作。但是,如果我尝试在 IIS 上进行部署,它就会挂起。
用于列出位于文件夹中的图像文件的代码 sn-p:
public static Google.Apis.Drive.v3.Data.FileList ListFiles(DriveService service, string folderId)
{
try
{
var request = service.Files.List();
request.PageSize = 100;
request.Fields = "nextPageToken, files(id, name)";
if (!String.IsNullOrEmpty(folderId))
{
request.Q = "'" + folderId + "' in parents " + " and mimeType='image/jpeg'";
}
return request.Execute();
}
catch (Exception ex)
{
throw new Exception("Request failed.", ex);
}
}
我很清楚 Google Drive API 支持用于 Web 应用程序的 OAuth 2.0 (ASP.NET MVC),如下所述: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web-applications-aspnet-mvc
请帮忙。谢谢。
【问题讨论】:
-
请提供您在浏览器或控制台上获得的确切错误详细信息。
-
请附上您的验证码。 IIS 服务器在哪里?我们说的是 Azure 吗?
-
我认为这与 IIS 配置有关。尝试检查 .NET 的 Web applications (ASP.NET MVC) 实现。它说您需要“将重定向 URI 设置为 your_site/AuthCallback/IndexAsync”等等。此外,来自 github forum 的一些指针可能会有所帮助。
-
我认为 Google 提供的大多数示例代码都可用于已安装的应用程序。它不适用于 Web 应用程序。
标签: asp.net iis asp.net-web-api asp.net-core google-drive-api