在vb.net中返回HTTP状态码201的最佳方法

时间:2016-10-10 13:11:56

标签: vb.net rest http-status-codes

我在vb.net中编写一个REST服务,我想允许创建项目,我想知道哪个是将201状态代码(或403,如果失败)返回给客户端的最佳方法?

我的示例代码是:

<WebInvoke(method:="POST", UriTemplate:="create/{var}", BodyStyle:=WebMessageBodyStyle.Bare, RequestFormat:=WebMessageFormat.Xml, ResponseFormat:=WebMessageFormat.Xml)>            
Public Function CreateTest(ByVal Var As String) As Boolean

    Dim Result As Boolean = True

    'do my processing here and then...
    Throw New WebFaultException(Net.HttpStatusCode.Created) 

    Return Result

End Function

Throw New WebFaultException(Net.HttpStatusCode.Created)这样做的正确方法是什么?

0 个答案:

没有答案