我在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)
这样做的正确方法是什么?