sendgrid / sendgrid-csharp

The Official Twilio SendGrid C#, .NetStandard, .NetCore API Library
https://sendgrid.com
MIT License
1.08k stars 584 forks source link

"Event Webhook C# Code Example" missing namespaces #1164

Closed dtsob75 closed 2 years ago

dtsob75 commented 2 years ago

I am attempting to implement the Inbound mail parser and I found the "Event Webhook C# Code Example" on the Sendgrid website. However, I am getting a couple of errors on the controller code. Specifically, in the following:

var root = _httpContextAccessor.HttpContext.Current.Server.MapPath("~/App_Data");

issues error: Request.Content.ReadAsMultipartAsync "HttpContext does not contain a definition for 'Current'"

And:

await Request.Content.ReadAsMultipartAsync(provider);

issues error: Request.Content.ReadAsMultipartAsync "HttpRequest does not contain a definition for 'Content'"

Our api is using ASP.Net Core 5.0. I assume there are some references missing, but I am not able to find out what they are.

I initially sent this issue to the SendGrid support, but they replied that I should contact this project....

JenniferMah commented 2 years ago

Hi @dtsob75! Are these the code samples you are referring to? Can you also include what version of Sendgrid-csharp you are using?

aaronhudon commented 2 years ago

@JenniferMah this example does not compile with .NET Core. Please advise on how to parse given a HttpRequest from an API endpoint (not MVC)

childish-sambino commented 2 years ago

Does this comment help? https://github.com/dotnet/aspnetcore/issues/3322#issuecomment-404560205

childish-sambino commented 2 years ago

Closing due to inactivity. Please re-open this issue or open a new GitHub issue if you still need help.