I have got a web service programmed in c# / asp.net.
[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 } }
How is it possible to return error 403 out of this web service? I can throw an exception - but this shows the exeption and not his error.
Any ideas?
If you were using MVC you'd do the following:
return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
1.4m articles
1.4m replys
5 comments
57.0k users