Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7526579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:52:13+00:00 2026-05-30T03:52:13+00:00

I have an iPad app that submits orders to an ASP.NET MVC web site

  • 0

I have an iPad app that submits orders to an ASP.NET MVC web site via form post. It is posting JSON which can be fairly large for a mobile device to send (200~300K) under certain conditions. I can GZip the form post but then my asp.net mvc chokes on the gzipped content.

How can I handle a GZipped form post in asp.net mvc?

UPDATE:

Darin’s answer puts me on the right track but I still have no idea how to do what he suggests, so here is where I am at:

Have this code to decompress a string:

http://dotnet-snippets.com/dns/compress-and-decompress-strings-SID612.aspx

And I get the string like so:

StreamReader reader = new StreamReader(Request.InputStream);
string encodedString = reader.ReadToEnd();

but this gives me the error:

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters.

EDIT – COMPLETED CODE

I am using asp.net MVC and this is working great for me. I also had to deal with some other encoding that happens when my gzipping occurs:

[Authorize]
[HttpPost]
[ValidateInput(false)]
public ActionResult SubmitOrder()
        {

            GZipStream zipStream = new GZipStream(Request.InputStream, CompressionMode.Decompress);
            byte[] streamBytes = ReadAllBytes(zipStream);
            var result = Convert.ToBase64String(streamBytes);
            string sample = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(result));
            string escaped = Uri.UnescapeDataString(sample);

 // escaped now has my form values as a string like so: var1=value1&var2=value2&ect...

//more boring code

}



 public static byte[] ReadAllBytes(Stream input)
        {
            byte[] buffer = new byte[16 * 1024];
            using (MemoryStream ms = new MemoryStream())
            {
                int read;
                while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
                {
                    ms.Write(buffer, 0, read);
                }
                return ms.ToArray();
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:52:15+00:00Added an answer on May 30, 2026 at 3:52 am

    You can do this without a custom model binder. Write an Action that accepts HttpPostedFileBase, i.e, treat this as a file upload.

        [HttpPost]
        public ActionResult UploadCompressedJSON(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                GZipStream zipStream = new GZipStream(file.InputStream, CompressionMode.Decompress);
                byte[] streamBytes = ReadAllBytes(zipStream);
                var result = Convert.ToBase64String(streamBytes);
            }
            return RedirectToAction("Index");
        }
    

    You are going to need to change your client side code to send a file upload request but that should be fairly easy. For example you can look at this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPad app that uses custom fonts though the UIAppFonts elements in
I have an iPad app that has a UITableViewController that implements the NSFetchedResultsControllerDelegate .
I have this iPad app using Storyboard. There are some file that are marked
I know that after I have deployed my ipad/iphone app into App Store, it
I have an iPad app that I would like to make Universal, however this
I have an ipad app that when you are in landscape view, the view
I have an ipad app that is loading data remotely into core data, I
I'm building an iPad app that will have multiple paper pages and I'd like
I have an iPhone app that I'd like to convert to an iPad app.
I've got an iPad app that I absolutely need to have in just landscape,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.