-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebAPI V3 with ASP.NET WebAPI #259
Comments
At first glance, I'm not sure what the issue is, but reading this http://stackoverflow.com/a/28806198 makes me think that a careful examination of all asynchronous calls are in order. I'm leaving this open and putting it on our backlog for further review. Thanks! |
I read through the forum message from http://stackoverflow.com/a/28806198, I swapped all my signatures to make sure everything was async/await and that appeared to work. Updated Code:
Also, I had to apply await to |
Thanks for sharing your solution with the community! Please email us at dx@sendgrid.com with your T-shirt size and mailing address :) |
Received your email, thanks! We appreciate the kind words. |
I was using the exact same code but I get an runtime error "A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Core.dll Additional information: 'SendGrid.CSharp.HTTP.Client.Response' does not contain a definition for 'GetAwaiter'" I am wondering how are you able to get around it? I am using .Net 4.5.2 and SendGrid 7.0.3 and SendGrid.CSharp.HTTP.Client 2.0.4.
|
I believe there is an issue with the function return signature, as your return value is void. Check this out: http://theburningmonk.com/2012/10/c-beware-of-async-void-in-your-code/ |
I am targeting .NET Framework 4.6.1 @PandaBoy00 , |
Thanks for the follow up! |
I tried However, I am getting following error:
Is await supported anymore? |
@shyamal890 Could you please provide the relevant code so we can help you troubleshoot? |
@shyamal890 I think the GetAwaiter method isn't implemented in the HTTP.Client. If you use await, you will get that error. |
@PandaBoy00 Ya, I thought so but the code in the issue do use await method. I wonder if I am doing something wrong. @thinkingserious Here is my code implementation:
|
@shyamal890 it depends on what you want to do with the await. I have tried several times with the await and never got it to work becox it is missing the implementation in the dependency (CSharp.HTTP.Client). The only wait I got it to work was without the await keyword. Maybe you can try and move the await to the caller method? |
Looking deeper into the client, perhaps the issue is here: https://github.com/sendgrid/csharp-http-client/blob/master/CSharpHTTPClient/Client.cs#L245, because of the Thoughts? |
We received your CLA @PandaBoy00! Thanks! |
What does CLA mean? |
So finally can I use await or not possible as of now. Any alternative method? |
This solution appears to work: #259 (comment) But we will investigate this deeper for a proper fix: #259 (comment) |
@shyamal890 please follow this ticket: sendgrid/csharp-http-client#9 Though, I'll post an update here when we are able to fix. |
@shyamal890, @PandaBoy00, @b1tzer0, I believe I've made a proper fix, if you have a moment, please take a look:
I'm planning to merge this one in today and then update the dependency here. It looks like this will be a breaking change. |
This is similar to issue #235
Originally, under 7.0.1 I found that when running as a synchronous operation the system would stop processing when it would hit the POST method on SendGridClient. I found that it would process if I ran the task in its own thread, but when running in its own thread I would get the following exception:
System.InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.
I updated today to version 7.0.3 using the synchronous operation, it continued processing the page as expected, however; was presented with the same error message as though it was processed from a second thread.
Error Message:
System.InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.
Below is some code (I am posting more than what is probably necessary, but it will give you more to look at):
ApiBaseController.cs:
ProvisionController.cs:
SendGridClient.cs
Now the email is sent successfully, however; the overall response for the call to POST results in a failure. I think this is likely due to a POST to SendGridClient while doing a POST to ASP.NET WebAPI.
The text was updated successfully, but these errors were encountered: