Fixing the Elm middleware to check if request has form content

With a change to HttpAbstractions, ReadFormAsync throws if called on a request whose content type is not
not form encoded content.
This commit is contained in:
Praburaj 2015-03-23 21:15:55 -07:00
parent 105d3353cf
commit cb159a678a
1 changed files with 8 additions and 2 deletions

View File

@ -93,8 +93,14 @@ namespace Microsoft.AspNet.Diagnostics.Elm
NamePrefix = string.Empty
};
var isRedirect = false;
var form = await context.Request.ReadFormAsync();
if (form.ContainsKey("clear"))
IFormCollection form = null;
if (context.Request.HasFormContentType)
{
form = await context.Request.ReadFormAsync();
}
if (form != null && form.ContainsKey("clear"))
{
_store.Clear();
context.Response.Redirect(context.Request.PathBase.Add(_options.Path).ToString());