OwinContext.Request parsing multiple pieces / form-data?

Is there an easy way to parse information from multiple data parts / forms from an OwinContext.Request instance ?

I know how to do this using HttpContext.Current.Request.Form.Get () , but I'm not sure if I really want to do this in the Owin pipeline.

I know I can use .ReadFormAsync () to get an IFormCollection , which seems to work fine for standard views, but with data from multiple parts / forms after this column value, content type, and variable name are all passed into the key. So I can't just do formVars.Get ("VariableName") because it's not a variable name, it's a composite. It doesn't seem like it should be, though ... right?

public AppFunc PreAuthMiddleware(AppFunc next) {
  AppFunc appFunc = async (IDictionary<string, object> environment) => {
    IOwinContext context = new OwinContext(environment);
    IFormCollection formVars = await context.Request.ReadFormAsync();

    ... Now What ...

    await next.Invoke(environment);
  };
  return appFunc;
}

      

I was hoping that accessing form variables and files would be as easy as using HttpContext , but it looks like more work can be done.

If anyone has any idea about this please let me know. Otherwise, I'll probably just end up hacking the key names together if I see the main content type being multipart / form-info.

+3


source to share





All Articles