-
-
Notifications
You must be signed in to change notification settings - Fork 328
Description
In ASP.NET MVC5 the Request.QueryString and Request.Headers objects are of type System.Collections.Specialized.NameValueCollection - a type that does not exist in .NET Standard 1.4. In the guides I've written, and even in the ShopifySharp documentation, we tell users to pass those objects to the various AuthorizationService.IsValidX functions, but in v4+ those functions now expect a list of KeyValuePair<string, StringValues>.
For those reading this issue wondering how to get around this, for now you can create this extension method and then call Request.QueryString.ToKvps() or Request.Headers.ToKvps() and pass the result to the auth methods:
namespace MyNamespace
{
public static class Extensions
{
public List<KeyValuePair<string, StringValues>> ToKvps(this System.Collections.Specialized.NameValueCollection qs)
{
Dictionary<string, string> parameters = qs.Keys.Cast<string>().ToDictionary(key => key, value => qs[value]);
var kvps = new List<KeyValuePair<string, StringValues>>();
parameters.ToList().ForEach(x =>
{
kvps.Add(new KeyValuePair<string, StringValues>(x.Key, new StringValues(x.Value)));
});
return kvps;
}
}
}I'd like to explore fixing this in the package without adding an extra dependency. I'm not sure that's possible though, because even including the above extension method in ShopifySharp would require a reference to the type which simply isn't available.