Request.Form Is Empty When Posting To ASPX Page

4.91 (11 votes)

A couple of threads have been posted recently to the ASP.NET forums complaining that values posted to ASPX files are mysteriously disappearing. This post looks at the most likely cause and provides some solutions.

In each reported case, the scenario was very similar - the application in question was an ASP.NET 4.5 Web Forms app, developed in Visual Studio 2013 or 2015. The people reporting the issue were trying to post values using an HTTP POST request to a web form (.aspx file), in one case from an HTML file within the same application, and in the other case, from a browser plugin. The example form provided in one post looked valid enough:

<form action="/Receiver.aspx" method="post">
    <input name="Field1" type="text" value="1" id="Field1" /><br />
    <input name="Field2" type="text" value="some text information here" id="Field2" /><br />
    <input id="Submit1" type="submit" value="submit" />

But when the form was posted to Receiver.aspx, the values for Request.Form["Field1"] and Request.Form["Field2"] were empty. Even when debugging, the entire Request.Form collection is seen to be empty:

Empty Request.Form

When checking the browser's developer tools Network tab, an interesting fact is revealed - the POST request is successfully completed but immediately followed by a GET request:

Empty Request.Form

This combination of request clears the form data that was posted so that when the second request happens, no data is available,

The culprit is Friendly URLs, which I wrote about in a previous article. Friendly URLs is a framework for managing extensionless URLs in a Web Forms site. It is enabled by default in ASP.NET 4.5 Web Forms sites which are created using the Visual Studio (2013 and 2015) Web Forms application template. The HTML form in this example is designed to post to Receiver.aspx, and the Friendly URLs will take requests that include the file extension and issue an HTTP 301 - Moved Permanently response, directing the browser to make a new (GET) request for the same resource without the file extension.


There are three solutions:

  1. Update the form's action to remove the file extension

  2. Amend the configuration for Friendly URLs You will find this in the RouteConfig.cs file in the App_Start folder. The configuration to change is the AutoRedirect mode which by default is set to RedirectMode.Permanent. Comment this setting out:

    public static void RegisterRoutes(RouteCollection routes)
        var settings = new FriendlyUrlSettings();
        //settings.AutoRedirectMode = RedirectMode.Permanent;

    This will stop requests with file extnesions from being redirected

  3. Disable Friendly URLs

    Comment out the entire body of the RegisterRoutes method in the RouteConfig.cs file.


This post was made in response to a rash of similar questions being posted to the ASP.NET forums. It explains how Friendly URLs could be one possible reason for empty form collections in an ASP.NET 4.5 Web Forms web site and suggests suitable solutions.


You might also like...

Date Posted:
Last Updated:
Posted by:
Total Views to date: 7259


- satyabrata

Thank you.

- Fredrik

It worked. Thank you!

- federico


- Arkady

Thank you!
I spent a day to understand what problem is before I found your article!
But I made RedirectMode.Off instead of comment.

- flyingtigerfan

Thanks - spent hours trying to figure this out. I'm out of date and trying to start working on some simple things - and this was absolutely costing me more hair.

Recent Comments

Obinna Okafor 26/05/2017 16:16
In response to Razor Pages - The Elevator Pitch
Thank you for this wonderful piece, Mike. I need more of these...Keep them coming - anything more...

Cyrus 26/05/2017 06:00
In response to Razor Pages - The Elevator Pitch
There are some concern about razor pages performance. Is it faster or slower than MVC? would you a a...

Cyrus 26/05/2017 05:44
In response to Razor Pages - Understanding Handler Methods
well done, thank you....

Satyabrata Mohapatra 23/05/2017 11:41
In response to Razor Pages - Understanding Handler Methods
Nice and easy !! Great post....

Cyrus 16/05/2017 19:55
In response to Razor Pages - Getting Started With The Preview
There is something wrong related to microsoft.dotnetcore.mvc.taghelpers! if you remove it from page...

Cyrus 16/05/2017 10:18
In response to Razor Pages - Getting Started With The Preview
well done mike, it was very useful, I really appreciate that....

Satyabrata Mohapatra 16/05/2017 07:21
In response to Razor Pages - Getting Started With The Preview
Finally!!!! web pages in core!!! Super excited !!!! Thank u sir for sharing.....Awaiting on...

Daniele 14/03/2017 10:24
In response to Working With Zip Files In ASP.NET MVC
is it possible give to the user a progress bar of the zipping process? Thanks in advance. ...

Suraj 13/03/2017 22:20
In response to Working With Zip Files In ASP.NET MVC
Very nice article. Thanks....

Satyabrata Mohapatra 19/02/2017 03:01
In response to Free SSL Certificates On IIS With LetsEncrypt
Thanks for sharing. Learned a lot !!...