gpt4 book ai didi

c# - ASP.NET Web API - 测试错误 : an error has occurred - how to fix it?

转载 作者:行者123 更新时间:2023-12-03 03:35:23 29 4
gpt4 key购买 nike

我的 ASP.NET Web API 项目工作正常,但当我想在服务器上运行它时,我无法提取数据。我使用的是 Azure SQL 数据库,在本地服务器上没有问题。

我不明白为什么会收到此错误

 System.InvalidOperationException: an error has occurred.   
The given header was not found

StackTrace
at System.Net.Http.Headers.HttpHeaders.GetValues(String name)
at RayTech.API.Security.ApiKeyHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in C:\Users\Enesray\Source\Repos\RayTechWebApi\RayTech.API\Security\ApiKeyHandler.cs:line 23 at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()

web.config:

<add name="RayTechDbEntities" 
connectionString="metadata=res://*/RayTechModel.csdl|res://*/RayTechModel.ssdl|res://*/RayTechModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=*******;initial catalog=RayTechDb;user id=********;password=********;MultipleActiveResultSets=True;App=EntityFramework&quot;"
providerName="System.Data.EntityClient" />

链接:

最佳答案

使用azure数据库时,需要为Azure Web应用程序的IP设置防火墙,以便Azure Web应用程序可以访问数据库。

关于c# - ASP.NET Web API - 测试错误 : an error has occurred - how to fix it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73529419/

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