onactionexecuting

How to redirect from OnActionExecuting in Base Controller?

我们两清 提交于 2019-12-17 05:33:49
问题 I have tried two ways: Response.Redirect() which does nothing, as well as calling a new method inside of the Base Controller that returns an ActionResult and have it return RedirectToAction()... neither of these work. How can I do a redirect from the OnActionExecuting method? 回答1: public override void OnActionExecuting(ActionExecutingContext filterContext) { ... if (needToRedirect) { ... filterContext.Result = new RedirectResult(url); return; } ... } 回答2: It can be done this way as well:

Excel VBA Cannot call function with onaction

做~自己de王妃 提交于 2019-12-11 11:40:17
问题 I write a script for a ok button in a userform to create a delete button on the sheet to delete the whole line. The problem is that when I click the delete button, it cannot call the function I assigned with onaction parameter. Private Sub OKButton_Click() Dim emptyRow As Long 'Make Feuil1 Active Feuil1.Activate 'Determine emptyRow emptyRow = WorksheetFunction.CountA(Range("C:C")) + 1 Dim deleteButton As Button Dim t As Range Set t = ActiveSheet.Range(Cells(emptyRow, 2), Cells(emptyRow, 2))

ASP.NET MVC 3 OnActionExecuting causes infinite loop

房东的猫 提交于 2019-12-11 02:57:08
问题 I have that overriden OnActionExecuting method (to check before action execute if user is logged in) public class AuthenticationAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!filterContext.HttpContext.User.Identity.IsAuthenticated) { string redirectUrl = string.Format("?returnUrl={0}", filterContext.HttpContext.Request.Url.PathAndQuery); filterContext.HttpContext.Response.Redirect(FormsAuthentication.LoginUrl +

ASP.NET MVC controller actions with custom parameter conversion?

假如想象 提交于 2019-11-28 09:00:12
问题 I want to set up a ASP.NET MVC route that looks like: routes.MapRoute( "Default", // Route name "{controller}/{action}/{idl}", // URL with parameters new { controller = "Home", action = "Index", idl = UrlParameter.Optional } // Parameter defaults ); That routes requests that look like this... Example/GetItems/1,2,3 ...to my controller action: public class ExampleController : Controller { public ActionResult GetItems(List<int> id_list) { return View(); } } The question is, what do I set up to

How to redirect from OnActionExecuting in Base Controller?

◇◆丶佛笑我妖孽 提交于 2019-11-26 21:18:21
I have tried two ways: Response.Redirect() which does nothing, as well as calling a new method inside of the Base Controller that returns an ActionResult and have it return RedirectToAction()... neither of these work. How can I do a redirect from the OnActionExecuting method? public override void OnActionExecuting(ActionExecutingContext filterContext) { ... if (needToRedirect) { ... filterContext.Result = new RedirectResult(url); return; } ... } Randy Burden It can be done this way as well: filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { {"controller", "Home"}, {