Dear all how could im set response status in Asp.net Web service method ?
<WebMethod()> _
<Script.Services.ScriptMethod(responseFormat:=Script.Services.ResponseFormat.Json)> _
Public Function HelloWorld(ByVal name As String, ByVal userID As String, ByVal email As String, ByVal department As String, ByVal password1 As String) As String
Dim result As String
Try
Dim param(6) As SqlParameter
param(0) = New SqlParameter("@RefId", 1)
param(1) = New SqlParameter("@Name", name)
param(2) = New SqlParameter("@UserName", userID)
param(3) = New SqlParameter("@Email", email)
param(4) = New SqlParameter("@Department", department)
param(5) = New SqlParameter("@Password", password1)
' param(6) = New SqlParameter("@CreatedBy", "")
result = SqlHelper.ExecuteNonQuery(connStringShareMe, Data.CommandType.StoredProcedure, "Users_Insert", param)
Return "Done"
Catch ex As Exception
Return "500"
Return result
End Try
End Function
i want to return 500 status code in response how can i do it ?
You need to access via the static HttpContext class: