Exemplo n.º 1
0
 public override void ExecuteResult(ControllerContext context)
 {
     ContentResult result = new ContentResult
     {
         Content = Content,
         ContentEncoding = ContentEncoding ?? Encoding.UTF8,
         ContentType = ContentType
     };
     result.ExecuteResult(context);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Enables processing of the result of an action method by a custom type that inherits from the <see cref="T:System.Web.Mvc.ActionResult" /> class.
        /// </summary>
        /// <param name="context">The context in which the result is executed. The context information includes the controller, HTTP content, request context, and route data.</param>
        /// <exception cref="NotImplementedException"></exception>
        public override void ExecuteResult(ControllerContext context)
        {
            this.Result.ExecuteResult(context);

              var script = Sitecore.Context.Items[Constants.MvcWebFormRulesScriptKey] as string;
              if (!string.IsNullOrEmpty(script))
              {
            var content = new ContentResult { Content = InlineJs.SafeScriptWrapping.FormatWith(script) };
            content.ExecuteResult(context);
              }
        }
        public override void ExecuteResult(ControllerContext context)
        {
            string errorMessage = null;
            if (context.Controller.ViewData.ModelState.IsValid)
            {
                try
                {
                    service();
                    ObjectFactory.GetInstance<DatabaseContext>().SaveChanges();
                }
                catch (Exception e)
                {
                    e = this.Unwrap(e);
                    errorMessage = e.Message;
                }
            }

            if (context.HttpContext.Request.IsAjaxRequest())
            {
                ContentResult result = new ContentResult { Content = errorMessage ?? string.Empty };
                result.ExecuteResult(context);
                return;
            }

            if (!context.Controller.ViewData.ModelState.IsValid ||
                !string.IsNullOrEmpty(errorMessage))
            {
                if (onError != null) onError();

                if (context.RouteData.Values["action"].ToString().Equals("eliminar", StringComparison.OrdinalIgnoreCase))
                {
                    context.Controller.TempData.Add("message", errorMessage);
                }
                else
                {
                    context.Controller.ViewData.ModelState.AddModelError("", errorMessage);
                    errorView.ViewData = context.Controller.ViewData;
                    errorView.TempData = context.Controller.TempData;
                    errorView.ExecuteResult(context);
                    return;
                }
            }

            foreach (string key in context.HttpContext.Request.QueryString.Keys)
            {
                successAction.RouteValues.Add(key, context.HttpContext.Request.QueryString[key]);
            }
            successAction.ExecuteResult(context);
        }
        public override void ExecuteResult(ControllerContext context)
        {
            //if (context.RequestContext.HttpContext.Request.IsAjaxRequest())
            //{
            string destinationUrl = UrlHelper.GenerateContentUrl(Url, context.HttpContext);

            //JavaScriptResult result = new JavaScriptResult()
            //{
            //    Script = String.Format("<ajaxScript>window.authRedirect ? window.authRedirect('{0}') : window.location='{0}';</ajaxScript>", destinationUrl)
            //};
            //result.ExecuteResult(context);

            ContentResult result = new ContentResult();
            result.Content = HttpUtility.HtmlEncode(String.Format("<ajaxScript>window.location='{0}'</ajaxScript>", destinationUrl));
            result.ExecuteResult(context);
            //}
            //else
            //    base.ExecuteResult(context);
        }
Exemplo n.º 5
0
        public override void ExecuteResult(ControllerContext context)
        {
            var itemSeparator = ";";

            var sb = new StringBuilder();

            if (Data == null) {
                return;	// do nothing
            }

            var firstRow = Data.Rows.FirstOrDefault();

            if (firstRow == null) {
                return;	// do nothing
            }

            foreach (var field in firstRow.Fields) {
                sb.Append(field.DisplayName + itemSeparator);
            }

            sb.AppendLine();

            foreach (var record in Data.Rows) {
                foreach (var field in record.Fields) {
                    sb.Append((field.Data != null) ? field.Data.ToString() : String.Empty);
                    sb.Append(itemSeparator);
                }
                sb.AppendLine();
            }

            var result = new ContentResult {
                ContentType = "text/csv",
                Content = sb.ToString(),
                ContentEncoding = Encoding.Default
            };

            result.ExecuteResult(context);
        }
Exemplo n.º 6
0
 public override void ExecuteResult(ControllerContext context)
 {
     var cr = new ContentResult();
     if (Mode == RenderMode.Html)
     {
         cr.ContentType = "text/html";
         cr.Content = mHTML;
     }
     else if (Mode == RenderMode.Text)
     {
         cr.ContentType = "text/plain";
         cr.Content = mText;
     }
     else if (Mode == RenderMode.Json)
     {
         JsonResult jr = new JsonResult();
         jr.Data = new
         {
             mMessage.From,
             mMessage.To,
             mMessage.CC,
             mMessage.Bcc,
             mMessage.Headers,
             mMessage.Priority,
             mMessage.ReplyToList,
             mMessage.Sender,
             mMessage.Subject,
             mMessage.SubjectEncoding
         };
         jr.ExecuteResult(context);
         return;
     }
     else
     {
         new SmtpClient().Send(mMessage);
         if (Mode == RenderMode.SendWithJson)
         {
             var jr = new JsonResult();
             jr.Data = new { success = true };
             jr.ExecuteResult(context);
             return;
         }
         cr.Content = "OK";
     }
     cr.ExecuteResult(context);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Renders the correct result to the client
        /// </summary>
        public override void ExecuteResult(ControllerContext context)
        {
            //finalize the content
            if (this.Element is CobaltControl) {
                (this.Element as CobaltControl).PerformFinalize();
            }

            //execute a content result with the markup
            ContentResult result = new ContentResult() {
                Content = this.Element.ToString(),
                ContentType = this.ContentType,
                ContentEncoding = this.Encoding
            };

            //and finalize the content
            result.ExecuteResult(context);
        }