本文整理汇总了C#中System.Web.Mvc.ActionExecutedContext类的典型用法代码示例。如果您正苦于以下问题:C# ActionExecutedContext类的具体用法?C# ActionExecutedContext怎么用?C# ActionExecutedContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionExecutedContext类属于System.Web.Mvc命名空间,在下文中一共展示了ActionExecutedContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:antgerasim,项目名称:RealWorldMvc,代码行数:7,代码来源:RequriesCategoryListAttribute.cs
示例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
};
}
}
开发者ID:the404,项目名称:bigline,代码行数:35,代码来源:JsonpFilterAttribute.cs
示例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;
}
}
}
开发者ID:roosteronacid,项目名称:madtastisk,代码行数:32,代码来源:AlternateOutputAttribute.cs
示例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);
}
}
}
}
开发者ID:jaecheol-jeong,项目名称:NewsReaderTest,代码行数:33,代码来源:MobileOnlyAttribute.cs
示例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);
}
开发者ID:luowei98,项目名称:YiHe,代码行数:25,代码来源:UserFilter.cs
示例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);
}
}
}
}
}
}
开发者ID:xwyangjshb,项目名称:cuyahoga,代码行数:27,代码来源:LocalizationFilter.cs
示例7: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
//_logger.InfoFormat(CultureInfo.InvariantCulture,
// "Executed action {0}.{1}",
// filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
// filterContext.ActionDescriptor.ActionName);
}
开发者ID:nathanbedford,项目名称:ScaffR-Generated,代码行数:7,代码来源:LogFilter.cs
示例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();
}
}
}
开发者ID:merwan,项目名称:planning_dotnet,代码行数:30,代码来源:NHibernateActionFilter.cs
示例9: OnActionExecuted
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
Log.InfoFormat("Done executing {0}.{1}.",
filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
filterContext.ActionDescriptor.ActionName
);
}
开发者ID:Niels-V,项目名称:Glimpse.Log4Net,代码行数:7,代码来源:HomeController.cs
示例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);
}
开发者ID:ToJans,项目名称:MVCExtensions,代码行数:7,代码来源:FlashInvalidModelStateAttribute.cs
示例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 );
}
}
开发者ID:BenjaminAbt,项目名称:samples.ASPNETMVC,代码行数:10,代码来源:HtmlMinimyFilter.cs
示例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);
}
开发者ID:paulsuart,项目名称:rebelcmsxu5,代码行数:11,代码来源:SupportsClientNotificationsAttribute.cs
示例13: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
// After controller logic
base.OnActionExecuted(filterContext);
filterContext.HttpContext.Response.Write(this.Msg);
}
开发者ID:Hagge,项目名称:Mvc4Search,代码行数:7,代码来源:MyCustomActionFilter.cs
示例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);
}
开发者ID:jfvaleroso,项目名称:WMS_Revised,代码行数:27,代码来源:AuditAttribute.cs
示例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;
}
开发者ID:vasistbhargav,项目名称:net,代码行数:7,代码来源:JsReportStream.cs
示例16: OnActionExecuted
/// <summary>
/// This provides simple feedback to the modelstate in the case of errors.
/// </summary>
/// <param name="filterContext"></param>
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (filterContext.Result is RedirectToRouteResult)
{
try
{
// put the ModelState into TempData
TempData.Add("_MODELSTATE", ModelState);
}
catch (Exception)
{
TempData.Clear();
// swallow exception
}
}
else if (filterContext.Result is ViewResult && TempData.ContainsKey("_MODELSTATE"))
{
// merge modelstate from TempData
var modelState = TempData["_MODELSTATE"] as ModelStateDictionary;
foreach (var item in modelState)
{
if (!ModelState.ContainsKey(item.Key))
ModelState.Add(item);
}
}
base.OnActionExecuted(filterContext);
}
开发者ID:kahanu,项目名称:iCalendarSharp,代码行数:31,代码来源:BaseController.cs
示例17: OnActionExecuted
public void OnActionExecuted(ActionExecutedContext filterContext) {
var settings = _sslService.GetSettings();
if (!settings.Enabled) {
_orchardServices.Notifier.Warning(T("You need to configure the SSL settings."));
}
}
开发者ID:RasterImage,项目名称:Orchard,代码行数:7,代码来源:SecureSocketsLayersFilter.cs
示例18: OnActionExecuted
/// <summary>
/// Called by the ASP.NET MVC framework after the action method executes.
/// </summary>
/// <param name="filterContext">The filter context.</param>
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (filterContext == null || !filterContext.HttpContext.Request.IsAjaxRequest())
{
return;
}
// Preparing Json object for AJAX.success processing in forms.js javascript
string destinationUrl = string.Empty;
if (filterContext.Result is RedirectResult)
{
var result = filterContext.Result as RedirectResult;
destinationUrl = UrlHelper.GenerateContentUrl(result.Url, filterContext.HttpContext);
}
if (filterContext.Result is RedirectToRouteResult)
{
var result = filterContext.Result as RedirectToRouteResult;
var helper = new UrlHelper(filterContext.RequestContext);
destinationUrl = helper.RouteUrl(result.RouteValues);
}
// Rendered context is getting reloaded by AJAX.success in forms.js javascript
if (filterContext.Result is ViewResult)
{
return;
}
var jsonResult = new JsonResult { Data = new { resultType = "Redirect", redirectUrl = destinationUrl } };
filterContext.Result = jsonResult;
}
开发者ID:targitaj,项目名称:m3utonetpaleyerxml,代码行数:35,代码来源:FormValidatorAttribute.cs
示例19: OnActionExecuted
public void OnActionExecuted(ActionExecutedContext filterContext)
{
if(filterContext.Exception == null)
Database.Session.Transaction.Commit();
else
Database.Session.Transaction.Rollback();
}
开发者ID:torrenegra-inv,项目名称:Torreblanca_MVC,代码行数:7,代码来源:TransactionFilter.cs
示例20: OnActionExecuted
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (!filterContext.Controller.ViewData.ModelState.IsValid)
filterContext.Controller.ViewData[ValidationExtensions.FormNameKey] = Name;
base.OnActionExecuted(filterContext);
}
开发者ID:dpawatts,项目名称:zeus,代码行数:7,代码来源:ValidationGroupAttribute.cs
注:本文中的System.Web.Mvc.ActionExecutedContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论