Request.Form Is Empty When Posting To ASPX Page

4.92 (12 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.


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


- 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

Thomas 05/03/2018 00:59
In response to I'm Not Writing A Book On Razor Pages
There's a typo on this page: = true)] should be [BindProperty(SupportsGet = true)]...

Rolf Herbert 04/03/2018 19:25
In response to I'm Not Writing A Book On Razor Pages
So is MS deprecating razor Web Pages..? Is it dead..? I wish they would stop killing things so its...

Borut 17/02/2018 12:59
In response to I'm Not Writing A Book On Razor Pages
Mike, is it possible that Web Pages and Razor Pages "live" together in one web application? I a I...

hrboyce 09/02/2018 04:44
In response to I'm Not Writing A Book On Razor Pages
Mike, First thanks for doing this but I have to ask, any chance you would consider converting one of...

aziz sallam 07/02/2018 10:18
In response to I'm Not Writing A Book On Razor Pages
u are a great man...

Satyabrata Mohapatra 31/01/2018 11:36
In response to I'm Not Writing A Book On Razor Pages
This is a great news!!!! Thanks...

tangdf 30/01/2018 07:25
In response to I'm Not Writing A Book On Razor Pages
=> { o.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute()); }); The extension method does...

Obinna Okafor 30/01/2018 04:02
In response to I'm Not Writing A Book On Razor Pages
Thank you very much. I would like to see a project built from scratch using Razor Pages. And it show...

rachida Dukes 31/10/2017 13:52
In response to Customising Identity in Razor Pages
Thanks again for this wonderful tutorial. I followed all the steps in this section called: Adding...

Rachida 31/10/2017 12:06
In response to Customising Identity in Razor Pages
Thanks very much for this wonderful tutorial, it helped a lot....