locked
ASP.NET NameValueCollection Empty despite POST being visible in Wireshark RRS feed

  • Question

  • User436261338 posted

    So I have run into a problem. This is my environment: Visual Studio 2015 ASP.NET Solution and using IIS Express for debugging purposes.

    I am using Chrome's Postman to submit POST data to my application and despite seeing the form data in Wireshark, I am unable to see the data within my Request object in the Page.Load for the page that is being hit.

    What could I be missing?

    Wednesday, January 20, 2016 3:48 AM

Answers

  • User-821857111 posted

    Do you have Friendly URLs enabled? If so, what could be happening is that the response to the initial POST request is a 301 which tells the browser to issue a GET, thereby losing the form data. You can see this in the network tab of your favourite browser's web tools.

    If that is the case, you either disable FriendlyUrls if you are not using them (comment out the code in RouteConfig.cs) or comment out the AutoRedirectMode setting. Or if you are using FriendlyUrls, you can change the form's action to remove the .aspx.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 22, 2016 8:35 AM

All replies

  • User-821857111 posted

    Do you have Friendly URLs enabled? If so, what could be happening is that the response to the initial POST request is a 301 which tells the browser to issue a GET, thereby losing the form data. You can see this in the network tab of your favourite browser's web tools.

    If that is the case, you either disable FriendlyUrls if you are not using them (comment out the code in RouteConfig.cs) or comment out the AutoRedirectMode setting. Or if you are using FriendlyUrls, you can change the form's action to remove the .aspx.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 22, 2016 8:35 AM
  • User-798590995 posted

    I did resolve my problem and it was specific to the RouteConfig.cs solution and how FriendURLs were implemented. Interestingly enough, I saw your answer after
    finding out how to resolve it. See below: 

    My original Routconfig.cs was:

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

    I was finally able to get post data using the following instead:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.EnableFriendlyUrls();
    }
    Saturday, January 23, 2016 4:48 PM