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

  • Home
  • SEARCH
  • 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 8458477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:05:30+00:00 2026-06-10T13:05:30+00:00

I am using the normal way to configure Web APIs in my project, however,

  • 0

I am using the normal way to configure Web APIs in my project, however, I do have a legacy API which I need to support.

I configure the datetime format like this:

JsonMediaTypeFormatter jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
        jsonFormatter.SerializerSettings = new JsonSerializerSettings
        {
            NullValueHandling = NullValueHandling.Include,
            ContractResolver = new CamelCasePropertyNamesContractResolver()
        };
        var converters = jsonFormatter.SerializerSettings.Converters;
        converters.Add(new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-ddTHH:mm:ss" });

This is exactly what I want for most of the API controllers, however, with the legacy API, it needs to output DateTimes using the old MS AJAX format, like this:

/Date(1345302000000)/

So anyone know how I can specify a different JSON date formatter for one of my API modules and leave the Global Configuration as-is? OR any alternative, such as a config per API would be fine.
thanks

  • 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-10T13:05:31+00:00Added an answer on June 10, 2026 at 1:05 pm

    Web API has a concept called Per-Controller configuration just for scenarios like yours. Per-controller configuration enables you to have configuration on a per-controller basis.

    public class MyConfigAttribute : Attribute, IControllerConfiguration
    {
        public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
        {
            // controllerSettings.Formatters is a cloned list of formatters that are present on the GlobalConfiguration
            // Note that the formatters are not cloned themselves
            controllerSettings.Formatters.Remove(controllerSettings.Formatters.JsonFormatter);
    
            //Add your Json formatter with the datetime settings that you need here
            controllerSettings.Formatters.Insert(0, **your json formatter with datetime settings**);
        }
    }
    
    [MyConfig]
    public class ValuesController : ApiController
    {
        public string Get(int id)
        {
            return "value";
        }
    }
    

    In the above example, ValuesController would be using the Json formatter with your date time settings, but rest of the controllers in your would be using the one on GlobalConfiguration.

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

Sidebar

Related Questions

I have a problem with the normal way rails operates when using nested forms
I need to do: I am using the normal auto-fill function in Excel (double
If I have a jQuery plugin using the normal standard of: (function( $ ){
Logged into my Windows XP SP2 computer using my normal user account (which has
I have a function that generates normal random number matrix having normal distribution using
Hi, I'm doing a drop down menu in HTML/CSS the normal way; i.e., using
I have a DLL >> System.Data.SQLite.dll To use it in a normal way >
I'm using Sync Services in my application. I'm using the normal way of getting
when using PRISM the normal way to hookup things with unity is to define
I am using .Net 2 and the normal way to store my settings. I

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.