Azure-docs: How to test using core 3.1 - DefaultHttpRequest doesn't exist.

Created on 17 Dec 2019  Â·  12Comments  Â·  Source: MicrosoftDocs/azure-docs

Azure documentation issue guidance

Thanks for opening an issue in the Azure technical documentation repository.

We use GitHub issues as the primary channel for customer and community feedback about the Azure documentation.

Creating an issue

We prefer that you create documentation feedback issues using the Feedback link on the published article - the feedback control on the doc page creates an issue that contains all the article details so you can focus on the feedback part.

You can also create a feedback issue here in the repo. If you do this, please make sure your issue lists:

  • [ ] The relevant Azure service or technology.
  • [ ] A link to the published documentation article that you have feedback about.
  • [ ] Clear, specific feedback that the author can act on.

Pull requests and article contributions

If you know the change that is needed in an article, we encourage you to submit the changes directly using a pull request. If the change is large, or if you want to contribute an entire article, follow these guidelines:

  • [ ] Don't surprise us with a big pull request or a pull request with a new article! Submit an issue that describes the details of the proposed large change or new article.
  • [ ] Include the service or technology area.

We'll route the issue to the appropriate content team for review and discussion.

Tech support and product feedback

If you would like to contact Microsoft about other things, such as product feedback or tech support, please review these guidelines:


Dokumentdetails

⚠ Bearbeiten Sie diesen Abschnitt nicht. Er ist für die Verknüpfung von docs.microsoft.com zum GitHub-Artikel erforderlich.

Pri3 cxp needs-more-info product-issue triaged

Most helpful comment

you can probably replace DefaultHttpRequest with

var context = new DefaultHttpContext();
var defaultHttpRequest = context.Request;

All 12 comments

@curelom , Could you please share the document that you are referring to.

I have the same issue:
System.Private.CoreLib: Exception while executing function: HttpTriggerCSharp. EFAzureTest: Could not load type 'Microsoft.AspNetCore.Http.Internal.DefaultHttpRequest' from assembly 'Microsoft.AspNetCore.Http, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

 HttpRequest req = new DefaultHttpRequest(httpContext)
            {
                Method = "GET",
                Host = request.Host,
                Path = request.Path,
                QueryString = request.QueryString
            };

@curelom , @MarcHochleutner-Koellisch , Could you please share the document that you are referring to.

@curelom @MarcHochleutner-Koellisch This channel is for driving improvements towards MS Docs,If you have question specific to product , it would be best if you can create the product issue to the official Azure Functions Repo for better clarity.

@curelom So for now I will proceed with closure of this and If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.

@DixitArora-MSFT please reopen this issue. The issue is that the documentation provides examples that do not work with .net core 3.1 anymore.

Correct, my issue is with the documentation itself. Yes lease reopen

you can probably replace DefaultHttpRequest with

var context = new DefaultHttpContext();
var defaultHttpRequest = context.Request;

I agree with the OP, it's pretty dismal that the code sample in the documentation uses an class that is marked as internal (and for those who don't understand that, means us mere mortals can't use it) - nothing to do with the product, the majority know where to go if we have comments about the actual product....

Guidance on how to actually do this would be great. How do I now set the Request object for testing a controller?

I'm not sure if this is a documentation or a library issue, but in my case I tracked it down to a buffering flag in the Function framework used by ReadAsStringAsync() which means the call succeeds when the code is run via Kestrel but fails when run from unit tests.

Looking at the dependency chain, it should be referencing the fixed version (i.e. anything after this commit: https://github.com/Azure/azure-webjobs-sdk-extensions/commit/ff2440ac1f657ba76f5ab5a3cefafa3c55a50fdb#diff-fb4adb7f5777825d3a3b1767ad9071e4 )

I fixed it by running my own version of ReadAsStringAsync() and the code in the documentation works. It's a kludge, but it looks like an SDK issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varma31 picture varma31  Â·  3Comments

Agazoth picture Agazoth  Â·  3Comments

Favna picture Favna  Â·  3Comments

jebeld17 picture jebeld17  Â·  3Comments

behnam89 picture behnam89  Â·  3Comments