本文整理汇总了C#中System.Web.Mvc.ActionExecutedContext类的典型用法代码示例。如果您正苦于以下问题:C# ActionExecutedContext类的具体用法?C# ActionExecutedContext怎么用?C# ActionExecutedContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionExecutedContext类属于System.Web.Mvc命名空间,在下文中一共展示了ActionExecutedContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
var categories = Repository.FindAll<Category>();
var selectListItems = MappingEngine.Map<IEnumerable<Category>, IEnumerable<SelectListItem>>(categories);
var controllerBase = filterContext.Controller;
controllerBase.ViewData.Add(selectListItems);
}
示例2: OnActionExecuted
public override void OnActionExecuted(
ActionExecutedContext filterContext)
{
if (filterContext == null)
throw new ArgumentNullException("filterContext");
//
// see if this request included a "callback" querystring
// parameter
//
string callback = filterContext.HttpContext.
Request.QueryString["callback"];
if (callback != null && callback.Length > 0)
{
//
// ensure that the result is a "JsonResult"
//
JsonResult result = filterContext.Result as JsonResult;
if (result == null)
{
throw new InvalidOperationException(
@"JsonpFilterAttribute must be applied only
on controllers and actions that return a
JsonResult object.");
}
filterContext.Result = new JsonpResult
{
ContentEncoding = result.ContentEncoding,
ContentType = result.ContentType,
Data = result.Data,
Callback = callback
};
}
}
示例3: EmptyResult
void IActionFilter.OnActionExecuted(ActionExecutedContext aec)
{
var vr = aec.Result as ViewResult;
var aof = aec.RouteData.Values["alternateOutputFormat"] as String;
if (_requestSourceRestriction == RequestSourceRestriction.DenyRemoteRequests && !aec.RequestContext.HttpContext.Request.IsLocal)
{
aec.Result = new EmptyResult();
}
else
{
if (vr != null) switch (aof)
{
case "json": aec.Result = new JsonResult
{
JsonRequestBehavior = _jsonRequestBehavior,
ContentType = "application/json",
ContentEncoding = Encoding.UTF8,
Data = vr.ViewData.Model
};
break;
case "txt": aec.Result = new ContentResult
{
Content = "Not yet implemented",
ContentType = "text/plain",
ContentEncoding = Encoding.UTF8,
};
break;
}
}
}
示例4: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
string _isMobileCheckParams = filterContext.HttpContext.Request.Params["isMobile"];
string _userAgent = filterContext.HttpContext.Request.UserAgent;
if (string.IsNullOrWhiteSpace(_isMobileCheckParams) || !_isMobileCheckParams.ToUpper().Equals("Y"))
{
if (!(IsAppleDevice(_userAgent) || IsAndroidDevice(_userAgent)))
{
if (string.IsNullOrEmpty(RedirectUrl))
{
//throw new Exception("Mobile only!!");
var _errorMessage = new string[]
{
"mobile only",
filterContext.HttpContext.Request.Url.AbsoluteUri
};
string _model = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(_errorMessage);
filterContext.Result = new RedirectToRouteResult(
new System.Web.Routing.RouteValueDictionary { { "controller", "Error" }, { "model", _model } }
);
}
else
{
filterContext.HttpContext.Response.Redirect(RedirectUrl);
}
}
}
}
示例5: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
UserModel userModel;
if (filterContext.Controller.ViewBag.UserModel == null)
{
userModel = new UserModel();
filterContext.Controller.ViewBag.UserModel = userModel;
}
else
{
userModel = filterContext.Controller.ViewBag.UserModel as UserModel;
}
if (filterContext.HttpContext.User.Identity.IsAuthenticated)
{
YiHeUser yiheUser = filterContext.HttpContext.User.GetYiHeUser();
if (userModel != null)
{
userModel.IsUserAuthenticated = yiheUser.IsAuthenticated;
userModel.UserName = yiheUser.DisplayName;
userModel.RoleName = yiheUser.RoleName;
}
}
base.OnActionExecuted(filterContext);
}
示例6: TranslateMessages
private void TranslateMessages(ActionExecutedContext filterContext)
{
if (filterContext.Controller.ViewData.ContainsKey("Messages"))
{
MessageViewData messageViewData = (MessageViewData) filterContext.Controller.ViewData["Messages"];
foreach (KeyValuePair<string, IList<string>> messagesForType in messageViewData.Messages)
{
for (int i = 0; i < messagesForType.Value.Count; i++)
{
string baseName = String.Format("{0}.globalresources"
, filterContext.Controller.GetType().Namespace.Replace(".Controllers", String.Empty).ToLowerInvariant());
string originalMessage = messagesForType.Value[i];
string translatedMessage = this._localizer.GetString(originalMessage, baseName);
if (translatedMessage != originalMessage)
{
messagesForType.Value[i] = translatedMessage;
// Change the key of the messageParams if there were params for the original key
if (messageViewData.MessageParams.ContainsKey(originalMessage))
{
messageViewData.MessageParams.Add(translatedMessage, messageViewData.MessageParams[originalMessage]);
messageViewData.MessageParams.Remove(originalMessage);
}
}
}
}
}
}
示例7: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
//_logger.InfoFormat(CultureInfo.InvariantCulture,
// "Executed action {0}.{1}",
// filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
// filterContext.ActionDescriptor.ActionName);
}
示例8: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
var sessionController = filterContext.Controller as SessionController;
if (sessionController == null)
{
return;
}
using (var session = sessionController.Session)
{
if (session == null)
{
return;
}
if (!session.Transaction.IsActive)
{
return;
}
if (filterContext.Exception != null)
{
session.Transaction.Rollback();
}
else
{
session.Transaction.Commit();
}
}
}
示例9: OnActionExecuted
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
Log.InfoFormat("Done executing {0}.{1}.",
filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
filterContext.ActionDescriptor.ActionName
);
}
示例10: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
var modelState = filterContext.Controller.ViewData.ModelState;
if ((filterContext.Result is RedirectToRouteResult || filterContext.Result is RedirectResult) && !modelState.IsValid)
filterContext.Controller.TempData.Add(flashkey, modelState);
base.OnActionExecuted(filterContext);
}
示例11: OnActionExecuted
/// <summary>
/// Minification at the and of the request
/// </summary>
public void OnActionExecuted( ActionExecutedContext filterContext )
{
if ( IsSupportedContentType( filterContext ) )
{
filterContext.HttpContext.Response.Filter = new HtmlMinifyStream( filterContext.HttpContext.Response.Filter );
}
}
示例12: OnActionExecuted
/// <summary>
/// Ensures that the controller is of the required type, if so lets execution continue on the base class
/// </summary>
/// <param name="filterContext"></param>
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
var backOfficeController = GetController(filterContext.Controller);
if (!backOfficeController.Notifications.Any())
return;
base.OnActionExecuted(filterContext);
}
示例13: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
// After controller logic
base.OnActionExecuted(filterContext);
filterContext.HttpContext.Response.Write(this.Msg);
}
示例14: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
var request = filterContext.HttpContext.Request;
string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
string actionName = filterContext.ActionDescriptor.ActionName;
//Generate an audit
AuditModel audit = new AuditModel()
{
//Your Audit Identifier
AuditID = Guid.NewGuid(),
//Our Username (if available)
UserName = (request.IsAuthenticated) ? filterContext.HttpContext.User.Identity.Name : "Anonymous",
//The IP Address of the Request
IPAddress = request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? request.UserHostAddress,
//The URL that was accessed
AreaAccessed = request.RawUrl,
//Creates our Timestamp
TimeAccessed = DateTime.UtcNow,
//controller and action
Action = string.Format("Controller: {0} | Action: {1}", controllerName, actionName),
//result
Result = GetResult(filterContext.Result)
};
this.activityLogsService.CreateAuditLog(audit.UserName, audit.IPAddress, audit.AreaAccessed, audit.TimeAccessed, audit.Action, audit.Result);
}
示例15: JsReportStream
public JsReportStream(ActionExecutedContext context, EnableJsReportAttribute attr, Func<ActionExecutedContext, EnableJsReportAttribute, string, Task<Report>> renderReport)
{
_stream = context.HttpContext.Response.Filter;
_context = context;
_attr = attr;
_renderReport = renderReport;
}