Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

VB.NET my string message is not being returned from Badrequest("my message") in controller

$
0
0

So looking at the line

return BadRequest("Return invalid data message to caller")  

One would expect the message "Return invalid data message to caller" to be displayed back to the user. Instead all I see is the text:"Bad Request" with the status code of 400.  Anybody know why not? - Developed in VS2015 and targeting .net framework 4.5.1 - (that is what is installed on the server)

Here is the full response I get:

 -- response --
400 Bad Request
Cache-Control:  no-cache
Pragma:  no-cache
Content-Type:  text/html
Expires:  -1
Server:  Microsoft-IIS/7.5
X-AspNet-Version:  4.0.30319
X-Powered-By:  ASP.NET
x-frame-options:  SAMEORIGIN
Date:  Wed, 28 Sep 2016 15:43:28 GMT
Content-Length:  11

Bad Request

Namespace Controllers
    Public Class GetMyData
        Inherits ApiController

        Public Function GetValues(ByVal age As String, ByVal state As String, ByVal country As String) As IHttpActionResult

            Dim dm As New demoModel()
            Dim myData As New createDemoData

            dm = myData.getTotalData(age, state, country)
            If Not dm.dataisvalid Then
                return BadRequest("Return invalid data message to caller")  
            End If

            Return Ok(dm) 'return Ok (200) response with your model in the body

        End Function

    End Class
End Namespace


Viewing all articles
Browse latest Browse all 4850

Trending Articles