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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:55:26+00:00 2026-06-11T18:55:26+00:00

Let’s say I’ve got a simple Web API controller. I want to return a

  • 0

Let’s say I’ve got a simple Web API controller. I want to return a basic .NET type as a result. For example:

public class LoginController : ApiController
{
    [HttpPost]
    public bool Authenticate(LoginUserViewModel loginUserViewModel)
    {
        return true;
    }
}

I’m getting different results in different browsers even if the request is exactly the same for all of them.
In Chrome and IE7 I get Content-Type in Response Headers as application/json; charset=utf-8, and response value equal to “true“.
Firefox recognizes response Content-Type as application/xml; charset=utf-8 and sets response value to:

"<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>"

Is there any way to set response type on the server-side so it is always the same?
Thanks.

UPDATE: Here is JavaScript that I use to call my controller.

                    Ext.Ajax.request({
                    async: false,
                    url: 'Login/Authenticate',
                    defaultHeaders: { 'Accept': 'application/json' },
                    jsonData: user,
                    success: function (response, options) {
                        if (response.responseText !== 'true') {
                            Ext.Msg.alert('Error', 'Login failed, please try again');
                        } else {
                            document.location = 'Main.aspx';
                        }
                    },
                    failure: function (response, options) {
                        Ext.MessageBox.hide();
                        Ext.Msg.alert('Error', 'Server error. Cannot authenticate user.');
                    }
                });
  • 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-11T18:55:27+00:00Added an answer on June 11, 2026 at 6:55 pm

    This is because browsers send different Accept headers. Web API uses the accept header to determine the content-type of the response. By default Web API loads up a few different formatters into it’s configuration.Formatters collection.

    One way to force the response of to be a specific media-type is to remove all the existing formatters and add only the one you want.

    configuration.Formatters.Clear();
    configuration.Formatters.Add(new JsonMediaTypeFormatter());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you've got a table with a timestamp column, and you want to
Let's say I want to create an application, fairly simple CRUD with 3-5 tables.
Let's say I've got this very simple code: for(int i = 0; i <
So let's say I've got a simple XML document like this: <a> <b> <c>blah</c>
Let's say we have very simple Java class MyClass . public class MyClass {
Let's say I got a collection (simple grid) of invaders: In this image, only
Let's say I've got a simple form (but it's fairly long). This form submits
So I've got a web application, let's say with 2 sub domains a.domain.com and
Let's say i got a vps hosting with a dedicated ip, can i make
Let's say I've got a method that takes some arguments and stores them as

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.