1

I have a simple mock HttRequestMessage created by

    public static HttpRequestMessage FromJson(string uriString, string json = null)
    {
        var request = new HttpRequestMessage()
        {
            RequestUri = new Uri(uriString)
        };

        if (json != null)
        {
            request.Content = new HttpContentJson(json);
        }

        request.Properties.Add("HttpContext", new DefaultHttpContext() {  });


        return request;
    }

and when req.CreateErrorResponse(…) is run it gives a non-useful exception message

System.ArgumentNullException: 'Value cannot be null. Parameter name: provider'

So, what is provider?

See Sharp
  • 379
  • 1
  • 4
  • 11
  • @Nkosi I still get the error after trying both answers on there. I think this is something different. Notice that my exception message is different. – See Sharp Mar 03 '19 at 05:34
  • @Nkosi I ran into this same error and came up with a different solution than was outlined in the other answer. The other answers work when the test project targets full framework but doesn't appear to work when the test project targets .NET Core because Microsoft.AspNet.WebApi.Core/System.Web.Http (which is where those classes come from) doesn't have a .NET Standard version. – Kevin Secrist Mar 28 '19 at 19:08
  • @KevinSecrist Yes that would make sense given the major differences between the versions. As you mentioned, the linked answer is for full framework. – Nkosi Mar 28 '19 at 19:11
  • @Nkosi Would it be appropriate to reopen this question? I can post the solution I came up with – Kevin Secrist Mar 28 '19 at 20:41
  • 1
    @KevinSecrist This question however refers to the full framework. What I would suggest is you do up a new question with the problem you encountered. Making sure to note that it is for .net core. You can make reference back to this and other similar duplicates for the full framework. You can then post you answer as a self answer so that others can benefit from your findings. – Nkosi Mar 28 '19 at 20:45

0 Answers0