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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:13:55+00:00 2026-06-12T16:13:55+00:00

I’ve been banging on this all day and it’s time to get some help.

  • 0

I’ve been banging on this all day and it’s time to get some help. I am trying to call a .net MVC WebAPI application from some .net code. I am receiving a status code of 500 from the WebAPI with no real information even after upping the error detail policy to always. So I popped open Fiddler and now I can at least see a little bit more. This is what I’m receiving back from IIS via Fiddler after a call from .net:

{"Message":"An error has occurred.","ExceptionMessage":"User
credentials are
invalid.","ExceptionType":"System.Exception","StackTrace":" at
RemoteManagementService.Controllers.ProvisioningController.PostLogOn(RequestModel`1
request) etc…

(The stack trace references the closing bracket of my action method as the erroring line)

.net HttpClient calling code:

this.DefaultRequestHeaders.Add("Origin", "http://localhost:1181");  
this.DefaultRequestHeaders.Referrer = new Uri("http://localhost:1181/Provisioner/Edit/1");
    
//this.PostAsync<RequestModel<string>>(address + "PostLogOn", request, new media JsonMediaTypeFormatter())
this.PostAsync<RequestModel<string>>(address + "PostLogOn", request, new XmlMediaTypeFormatter())
    .ContinueWith(
        (postTask) =>
        {
            postTask.Result.Content.ReadAsAsync<string>().ContinueWith(
                (readTask) =>
                {
                    myvalue = readTask.Result;
                }).Wait();
        }).Wait();

jquery calling code:

jQuery.support.cors = true;

$.ajax({
    type: 'POST',
    url: 'http://me.mywebsite.com/provisioning/api/provisioning/PostLogOn',
    datatype: 'json',
    data: { datum: 'this is my data' },
    success: function (data) {
        alert(data);
    },
    error: function (data) {
        alert(data);
    }
});

What has really frustrated me is that when I make the same call using jquery, I seem to be able to initiate the controller action (I still get an error but that’s because I can’t format RequestModel<> in a valid way from my html page and am receive parsing exceptions after successfully entering the method)

jquery request from chrome:

POST /provisioning/api/provisioning/PostLogOn HTTP/1.1
Host: me.mywebsite.com
Connection: keep-alive
Content-Length: 21
Origin: http://localhost:1181
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.92 Safari/537.4
Content-Type: application/x-www-form-urlencoded
Accept: */*
Referer: http://localhost:1181/Provisioner/Edit/1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

.net HttpClient Request:

POST /provisioning/api/provisioning/PostLogOn HTTP/1.1
Accept: application/json
Origin: http://localhost:1181
Referer: http://localhost:1181/Provisioner/Edit/1
Content-Type: application/xml; charset=utf-8
Host: me.mywebsite.com
Content-Length: 420
Expect: 100-continue
Connection: Keep-Alive

And for good measure, the response I recieve(the only difference between jquery and .net being the size)

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: http://localhost:1181
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 10 Oct 2012 06:34:46 GMT
Content-Length: 823

I do not have any authorization attributes on my controller or actions. I have a session key but it’s not integrated into my framework and is simply data as part of my RequestModel<>. When I run the apps in debug mode from VS, everything works fine. This is only occurring after I deploy the WebAPI to my website. The jQuery call started working after I added the cors Origin handler into my API configuration startup which makes me think this is a cross domain issue, but the .net code has the same origin header… The biggest difference I’m seeing is that the ajax call is ultimately formatting things as form-urlencoded even though I specify a json datatype. I’ve tried both json and xml from .net to no avail. I’ve also tried a UrlEncodedMediaTypeFormatter but it’s apparently not smart enough to serialize my data. Interestingly, if I try a simple GET from the browser URL bar on a test action, I can get a response too. Do I need to tell HttpClient I’m going cross domain similar to jQuery.support.cors = true somehow?

Any suggestions or insights would be greatly appreciated as I’ve reached the limits of my Google skills and personal knowledge.

  • 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-12T16:13:56+00:00Added an answer on June 12, 2026 at 4:13 pm

    I have managed to resolve my issue. tugberk is correct in that it was a problem in my code. My original cross domain assumption was correct, when I added the cors message handler to my api configuration the issue was resolved and is the reason I was able to finally get the error message I had.

    The reason I was getting invalid credentials was because the connection string lookup (registry) was available when I ran on my development machine but not after I deployed to the IIS server. Deploying to a fully configured beta environment was successful. My confusion stemmed from initial cross domain problems and 14 hours of diagnosing the problem.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.