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 8995215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:35:24+00:00 2026-06-15T23:35:24+00:00

This is me publicly documenting my mistake so that if I or anyone does

  • 0

This is me publicly documenting my mistake so that if I or anyone does it again, they don’t have to spend 3 hours tearing their hair out trying to fix such a simple thing.

Context

I was sending an HttpRequest from one C# MVC ASP.NET application to another.
The applications require an HTTPS connection, and we are using URLRewrite to redirect an HTTP request to an HTTPS url.

One application was sending a POST request with some JSON data in the body, pretty standard stuff. The other application was set up to receive this data with an MVC controller class (CollectionAction and Insert methods for GET and POST respectively).

Symptoms of the problem

The receiving application was running the GET method (CollectionAction) instead of the POST action (ItemAction). The reason for this was that the request coming in to the application was in fact a GET request, and to top it off the JSON data was missing too.

I sent the header "x-http-method" to override the request method from GET to POST (I was already setting the request httpmethod to POST but this was being ignored). This worked but still I had no data being sent.

So now I am stuck pulling my hair out, because I can see a POST request with content-length and data being sent out and I have a GET request with no data or content-length coming in (but the headers were preserved)

  • 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-06-15T23:35:25+00:00Added an answer on June 15, 2026 at 11:35 pm

    Turns out I was using UriBuilder to take a base URL and apply a resource path to it. For example I would have “google.com” in my web.config and then the UriBuilder would take a resource like Pages and construct the url “google.com/Pages”. Unfortunately, I was not initializing the UriBuilder with the base URL, and instead was using a second UriBuilder to extract the host and add that to the path like so:

    public Uri GetResourceUri(string resourceName)
        {
            var domain = new UriBuilder(GetBaseUrl());
            var uribuilder = new UriBuilder()
            {
                Path = domain.Path.TrimEnd('/') + "/" + resourceName.TrimStart('/'),
                Host = domain.Host
            };
            var resourceUri = uribuilder.Uri;
            return resourceUri;
        }
    

    The problem with this code is that the scheme is ignored (HTTP:// vs https://) and it defaults to HTTP. So my client was sending out the request to an HTTP url instead of the required HTTPS url. This is the interesting part, URLRewrite was kicking in and saying that we needed to go to an HTTPS url instead so it redirected us there. But in doing so, it ignored the Http-Method and the POST data, which just got set to defaults GET and null. This is what the 2nd application could see at the receiving end.

    So the function had to be rewritten to this which fixed the problem:

    public Uri GetResourceUri(string resourceName)
        {
            var baseUrl = GetBaseUrl();
            var domain = new UriBuilder(baseUrl);
            var uribuilder = new UriBuilder(baseUrl)
            {
                Path = domain.Path.TrimEnd('/') + "/" + resourceName.TrimStart('/'),
            };
            var resourceUri = uribuilder.Uri;
            return resourceUri;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my dot files in Github publicly. This means that I have only
How do I comment this Enum so that the warning does not appear? Yes
This is regarding ASP.NET MVC. Let's say I have a web site that is
Raymond Chen has confirmed that there is no publicly documented way to do this.
Users on my site have a publicly-visible profile where they accept subscriptions via a
I have a model that has an attribute that referrers to when this object
Say i have a class that contains these items publicly accessible via properties: class
does anyone know of way I can change the existing display name publicly as
This should be a simple one: I have an observableArray object called To in
I'm sure this is publicly available somewhere but my google-fu has failed me. What

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.