My ASP.NET Web API project works fine but when I want to run it on a server I can’t pull the data. I’m using an Azure SQL database, I don’t have a problem on the local server.
I can’t figure out why am I getting this error
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:UsersEnesraySourceReposRayTechWebApiRayTech.APISecurityApiKeyHandler.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="data source=*******;initial catalog=RayTechDb;user id=********;password=********;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
Links:
- Screenshot on local server postman: https://i.hizliresim.com/4r24ie8.jpg
- Screenshot online site: https://i.hizliresim.com/gt6idph.jpg
- Google Chrome: https://i.hizliresim.com/tvhw63j.jpg
2
Answers
Refer this msdoc on sql databse
when using azure database,
setting the firewall
for the IP of Azure web app is required so that Azure web app can access the database.