我正在使用nopCommmerce 3.40,MVC 5
我有make插件,并为路线设置了一条行动路线
但我收到错误的样子:
Error executing child request for handler'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.
Child actions are not allowed to perform redirect actions
我的密码
[AdminAuthorize]
public ActionResult Configure()
{
return RedirectToRoute("PluginName.ActionName");
}
public ActionResult ActionName()
{
// i want to call/ return this from Configure mathod
}
路由提供者
routes.MapRoute("PluginName.ActionName", "Admin/Plugins",
new { controller = "Controller", action = "Action" },
new[] { "PluginName.ActionName.Controllers" }
).DataTokens.Add("area", "admin");
您收到的错误消息说明了一切。您不能在那里执行重定向。实际上,插件配置操作是使用子操作调用的,因此通常使用[ChildActionOnly]属性进行修饰。您可以在此答案中找到更详细的消息,为什么Asp.net MVC 2的子操作中不允许重定向结果。
例如,您应该重构代码以从其他位置调用重定向,例如主操作或应用于主操作的自定义操作过滤器。
但是,由于调用Configure操作的代码由于属于nopCommerce而不是插件而不可控制,因此最好的办法是动态注入自定义操作过滤器并在其中执行重定向。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句