locked
Handling a POST request in a C# (MVC?) running on Azure RRS feed

  • Question

  • I want to send a post request from a C++ client to a C# program in a WebRole on Azure.

    I think I now know how to get the WebRole running on Azure, but I haven't found any examples of servicing the POST request using C#.

    I suspect that I'd be best using MVC, but even then I'd really appreciate an example.

    Any pointers or examples would be welcome...

    http://www.ransen.com Cad and Graphics software

    • Moved by Jason Dot Wang Monday, November 12, 2012 2:49 AM This thread is about ASP.NET (From:Visual C# General)
    Friday, November 9, 2012 2:01 PM

Answers

  • Hi Owen,

     Welcome to MSDN Forum Support.

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.If you want to know the technological point about Azure,you can post its related post at Windows Azure Development.

      Sincerely,

      Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Just Karl Friday, January 17, 2014 10:48 PM
    • Marked as answer by Just Karl Monday, January 27, 2014 4:43 PM
    Monday, November 12, 2012 2:48 AM
  • Hello,

    Specifically, this should be asked in the ASP.Net MVC forum on forums.asp.net.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    • Proposed as answer by Just Karl Wednesday, January 22, 2014 3:39 PM
    • Marked as answer by Just Karl Monday, January 27, 2014 4:43 PM
    Friday, January 17, 2014 10:48 PM

All replies

  • I've found the answer by experimentation.

    Anyway, all you need to do is create an MVC4 project in VC2010 and much of the code is already there, with the default routing from arriving URI to C# function in a C# file called ValuesControllers.cs

    Inside that there are some already defined sample functions, and one of them is:

    ...
            // POSTapi/values
            public void Post([FromBody]string value)
            {
            }
    ...

    Now back to my question,which is answered on the first line:

    POST api/values HTTP/1.0
    Host: owenransenscloud.cloudapp.net

    User-Agent: HTTPTool/1.0
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 32

    User=GeorgeFormby&UserId=erewhon

    So the default MVC4 project already has a POST handler and the routing to handle it and even comments the POST handler with the POST expression to use.


    http://www.ransen.com Cad and Graphics software

    • Proposed as answer by Just Karl Friday, January 17, 2014 10:47 PM
    Saturday, November 10, 2012 11:01 AM
  • Hi Owen,

     Welcome to MSDN Forum Support.

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.If you want to know the technological point about Azure,you can post its related post at Windows Azure Development.

      Sincerely,

      Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Just Karl Friday, January 17, 2014 10:48 PM
    • Marked as answer by Just Karl Monday, January 27, 2014 4:43 PM
    Monday, November 12, 2012 2:48 AM
  • All of this stuff is new to me, so I'm mistake forums every now and then... will do as you suggest.


    http://www.ransen.com Cad and Graphics software

    Monday, November 12, 2012 5:35 AM
  • Hello,

    Specifically, this should be asked in the ASP.Net MVC forum on forums.asp.net.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    • Proposed as answer by Just Karl Wednesday, January 22, 2014 3:39 PM
    • Marked as answer by Just Karl Monday, January 27, 2014 4:43 PM
    Friday, January 17, 2014 10:48 PM