本文整理汇总了C#中System.Web.Mvc.ContentResult.ExecuteResult方法的典型用法代码示例。如果您正苦于以下问题:C# ContentResult.ExecuteResult方法的具体用法?C# ContentResult.ExecuteResult怎么用?C# ContentResult.ExecuteResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.ContentResult
的用法示例。
在下文中一共展示了ContentResult.ExecuteResult方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
ContentResult result = new ContentResult
{
Content = Content,
ContentEncoding = ContentEncoding ?? Encoding.UTF8,
ContentType = ContentType
};
result.ExecuteResult(context);
}
示例2: ExecuteResult
/// <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);
}
}
示例3: ExecuteResult
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);
}
示例4: ExecuteResult
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);
}
示例5: ExecuteResult
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);
}
示例6: ExecuteResult
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);
}
示例7: ExecuteResult
/// <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);
}