protected internal override bool BeforeActionInvocation(Controller controller, WorkContext work, string action, MethodInfo method, object[] args, ref object result) { if (work.IsGET) return false; work.NeedsSession(OnlyExistingSession); var session = work.Session; var supplied = work.WholeRequestAsJSONDataMap[TokenName].AsString(); if (session==null || !session.CSRFToken.EqualsOrdSenseCase(supplied)) throw new HTTPStatusException(NFX.Web.WebConsts.STATUS_400, NFX.Web.WebConsts.STATUS_400_DESCRIPTION, "CSRF failed"); return false; }
/// <summary> /// Override to add logic/filtering right before the invocation of action method. /// Return TRUE to indicate that request has already been handled and no need to call method body and AfterActionInvocation in which case /// return result via 'out result' paremeter /// </summary> protected internal abstract bool BeforeActionInvocation(Controller controller, WorkContext work, string action, MethodInfo method, object[] args, ref object result);
/// <summary> /// Override to add logic/filtering finally after the invocation of action method. Must return TRUE to stop processing chain /// </summary> protected internal abstract void ActionInvocationFinally(Controller controller, WorkContext work, string action, MethodInfo method, object[] args, ref object result);
public void Execute(Controller controller, WorkContext work) { work.Response.Redirect(URL); }
public void Execute(Controller controller, WorkContext work) { if (AttachmentFileName.IsNotNullOrWhiteSpace()) work.Response.Headers.Add(WebConsts.HTTP_HDR_CONTENT_DISPOSITION, "attachment; filename={0}".Args(AttachmentFileName)); var fid = Format.Guid; work.Response.ContentType = ImageCodecInfo.GetImageEncoders() .FirstOrDefault(enc => fid==enc.FormatID) .MimeType; Image.Save(work.Response.GetDirectOutputStreamForWriting(), Format); }
public void Execute(Controller controller, WorkContext work) { work.Response.WriteJSON( Data, Options); }
public void Execute(Controller controller, WorkContext work) { var txt = WebConsts.STATUS_404_DESCRIPTION; if (Description.IsNotNullOrWhiteSpace()) txt += (": " + Description); work.Response.StatusCode = WebConsts.STATUS_404; work.Response.StatusDescription = txt; if (work.RequestedJSON) work.Response.WriteJSON( new {OK = false, http = WebConsts.STATUS_404, descr = txt}); else work.Response.Write(txt); }
public void Execute(Controller controller, WorkContext work) { work.Response.WriteFile(LocalFileName, BufferSize, IsAttachment); }
public void Execute(Controller controller, WorkContext work) { var gen = (work.Portal!=null) ? work.Portal.RecordModelGenerator : Client.RecordModelGenerator.DefaultInstance; work.Response.WriteJSON( gen.RowToRecordInitJSON(Row, ValidationError, RecID, Target, IsoLang, ValueListLookupFunc) ); }
protected internal override bool BeforeActionInvocation(Controller controller, WorkContext work, string action, MethodInfo method, object[] args, ref object result) { return false; }
protected internal override bool AfterActionInvocation(Controller controller, WorkContext work, string action, MethodInfo method, object[] args, ref object result) { work.Response.SetNoCacheHeaders(Force); return false; }
public void Execute(Controller controller, WorkContext work) { work.Response.WriteJSON( Client.RecordModelGenerator.RowToRecordInitJSON(Row, ValidationError, RecID, Target)); }
public void Execute(Controller controller, WorkContext work) { work.Response.WriteJSON(Data, Options); }