Base solution for your next web application
Open Closed

Disable Camel Case Conversion On Application Action #2185


User avatar
0
bowlvan created

Hi,

Any action attribute can disable automatic camel case conversion of return Json result? Thanks.


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can check this issue <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/769">https://github.com/aspnetboilerplate/as ... issues/769</a>.

  • User Avatar
    0
    bowlvan created

    <cite>ismcagdas: </cite> Hi,

    You can check this issue <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/769">https://github.com/aspnetboilerplate/as ... issues/769</a>.

    So I need import Abp.Web.MVC into my Application project to using AbpJson? Possible to give a code sample for application function for reference? Thanks!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think I missunderstand your question.

    If you want your ApplicationService methods to return some other type of json result instead of Camel Case, you can define a custom ContractResolver for Json.NET like this.

    public class CustomCasePropertyNamesContractResolver : DefaultContractResolver
    {
    ...
    }
    

    Then in your Web API module's initialize method, use it instead of Camel Case resolver.

    Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CustomCasePropertyNamesContractResolver ();
    

    I hope this helps.