private static string ResolveHttpMethod(WidgetContext context)
{
string httpMethod = context.ViewContext?.HttpContext?.Request?.Method;
if (string.Equals(httpMethod, "get", StringComparison.OrdinalIgnoreCase))
{
httpMethod = "Get";
}
else
{
httpMethod = "Post";
}
if (httpMethod == "Post" && !string.IsNullOrEmpty(context.WidgetId))
{
// MA - We only want to use Post if we are the active widget.
// TODO - This needs to come from the value provider.
var form = context.ViewContext?.HttpContext?.Request?.Form;
if (!string.Equals(context.WidgetId, form[WidgetConventions.WidgetTarget], StringComparison.CurrentCultureIgnoreCase))
{
httpMethod = "Get";
}
}
return httpMethod;
}
}