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);
2.1m questions
2.1m answers
60 comments
57.0k users