Mark Topper
Mark Topper

Reputation: 664

Can not get post data

I'm trying to get post data into my controller.

It tells me that Request.Form does not exists, any ideas how I then get the post data for my application?

Here is my code:

Imports System.Net
Imports System.Web.Http

Public Class Car
    Public Name As String

    Public Sub New(ByVal iName As String)
        Name = iName
    End Sub
End Class

Public Class CarController
    Inherits ApiController

    Public Function PostCar() As Car
        Return New Car(Request.Form["name"])
    End Function
End Class

Upvotes: 0

Views: 51

Answers (1)

INDIA IT TECH
INDIA IT TECH

Reputation: 1898

Try below code,

Public Class CarController
    Inherits ApiController

    Public Function PostCar() As Car
        Return New Car(Request.Form("name"))
    End Function
End Class

Upvotes: 1

Related Questions