我有一个用c#/ASP.NET编写的Web服务.
[WebService(Namespace = "http://example.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
[System.ComponentModel.ToolboxItem(false)]
public class Service: System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Result GetData()
{
User user = GetUser();
if (user.LoggedIn)
{
return GetData();
}
else
{
// raise exception -> return error 403
}
}
怎么可能从该Web服务返回错误403呢?我可以抛出一个异常-但这显示的是经验,而不是他的错误.
有什么 idea 吗?