Search code examples
asp.netasp.net-mvc-3httpfiddler

How can i use a dump-file saved with HttpRequest.SaveAs to re-send the request to my localhost?


I'm troubleshooting an integration between an external service which posts multipart/form-data data to a Controller in MVC3.

On the production server I've captured erroneous request using HttpRequest.SaveAs to a file.

Is there any tool I can use to "replay" the request on my localhost so I can debug with Visual Studio?

(I've been trying with fiddler but I can't get it working right. If a dump a local request from a simple form with POST my controller recieves the files correctly. If i dump the same request and copy paste it into fiddler as raw and send the files are missing so there's something wrong.)

Since there's a built-in function to dump the request I'm thinking it might be some official way to resend the request as well. Is there a way to achieve this?


Solution

  • I got it working in fiddler if I do exactly this in the composer:

    1. Open the dumpfile in notepad
    2. Choose Parsed
    3. Only enter the Content-Type as headers (and let fiddler add the others even if they were the same)
    4. Paste the body of the request in request body from notepad

    POST: http://localhost/Controller/Action

    Request headers:

    Content-Type: multipart/form-data; boundary=fJP-UWKXo6xvqX7niGR0StXXFQwdKhHc9quF
    

    Request body:

    --fJP-UWKXo6xvqX7niGR0StXXFQwdKhHc9quF
    Content-Disposition: form-data; name="mmsimage"; filename="IMG_0959.jpg"
    Content-Type: image/jpeg; name=IMG_0959.jpg; charset=ISO-8859-1
    Content-Transfer-Encoding: binary
    
    <the encoded file goes here as jibberish>
    
    --fJP-UWKXo6xvqX7niGR0StXXFQwdKhHc9quF
    Content-Disposition: form-data; name="somefield"
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit
    
    value of somefield
    --fJP-UWKXo6xvqX7niGR0StXXFQwdKhHc9quF--