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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:47:38+00:00 2026-06-12T04:47:38+00:00

I have POST method like this public void PostMethod([FromBody]string param) { var test =

  • 0

I have POST method like this

    public void PostMethod([FromBody]string param)
    {
        var test = param;
    }

And simple JS script

<script type="text/javascript">
$.ajax({
    url: 'http://localhost:8101/sd/Localization/PostMethod',
    type: 'POST',
    data: {
        param: 'test'
    }
});
</script>

Ot work great. Ajax call is invoking the method BUT the param is null :/ always. I don`t know why. I can’t get it running. Can someone pls help me and show me the correct direction ?

// update

too check something i`ve created new project to be sure that i didn’t break something. Even in new project in default config I always get null

  • 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-12T04:47:40+00:00Added an answer on June 12, 2026 at 4:47 am

    Because param is a simple type, so to make it work for simple type, you just:

    <script type="text/javascript"> 
    $.ajax({ 
        url: 'http://localhost:8101/sd/Localization/PostMethod', 
        type: 'POST', 
        data:  {"" : 'test' } 
        } 
    }); 
    </script>
    

    If you still want to make POST request like yours, define you own strong type model:

    class YourModel
    {
        public string Param {get; set;}
    }
    

    So your action:

    public void PostMethod(YourModel param)   
    {   
        var test = param;   
    }
    

    Or use JObject:

    public void PostMethod(JObject param)   
    {   
        var test = param;   
    }
    

    More information:

    http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-1

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

Sidebar

Related Questions

I have this method: /** * POST */ public static void create(String body) {
i have a method in a class like this: public static void postEvents(List<RuleEvent> eventList)
I have a wcf service defined like this: [OperationContract] [WebInvoke(Method = POST, ResponseFormat =
Imagine a code like this one: @RequestMapping(value=/users, method=RequestMethod.GET) public String list(Model model) { ...
I have methods like this: [HttpPost] public ActionResult Delete(BaseViewModel vm) { public ActionResult Delete(string
I have a html form with the data by this post method 'form id='form1'
In a php-script i have a form, method is post, action-attribute is empty, which
I have a controller method with the following signature: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateValues(int id,
I have instantiated an object like this: GraphMatrixDirected<String, Integer> g g is passed to
I have a Windows Form with a ListBox. The form has this method public

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.