Is there a place where I can execute this session code for each request in nopCommerce?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 11 ans
It's in there just like that?  The RedirectToRoute line is commented out.
Il y a 11 ans
It wasn't doing anything. it didn't redirect to my plugin page.
Il y a 11 ans
Did you set a breakpoint on it and verify that you're actually getting to that line?
Il y a 11 ans
Yeah I did breakpoint. It hits the code but do anything.
and redirects to the page where user supposed to get there.
Il y a 11 ans
filterContext.Result = new RedirectResult("TestLogin");
It gives the following error

"Child actions are not allowed to perform redirect actions"
Il y a 11 ans
Use filterContext.IsChildAction to determine if you should perform the check on the session.
Il y a 11 ans
but how? Then to do what?
Il y a 11 ans
but how? Then to do what?
Il y a 11 ans
The complete error:

Server Error in '/' Application.

Child actions are not allowed to perform redirect actions.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Child actions are not allowed to perform redirect actions.

Source Error:


Line 281:        public static MvcHtmlString Widget(this HtmlHelper helper, string widgetZone)
Line 282:        {
Line 283:            return helper.Action("WidgetsByZone", "Widget", new { widgetZone = widgetZone });
Line 284:        }
Line 285:    }

Source File: c:\ApexProjects\Water_nopCommerce\Presentation\Nop.Web.Framework\HtmlExtensions.cs    Line: 283




The View that I am redirecting too:

@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
}

...
....
.....

if i Remove the  Layout = "~/Views/Shared/_ColumnsTwo.cshtml"; it will work fine.
Il y a 11 ans
The error is that a child action can't perform a redirect, right?  Well don't try to perform a redirect if you're in a child action:


protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
     if (!filterContext.IsChildAction
&& !filterContext.HttpContext.User.Identity.IsAuthenticated
&& (System.Web.HttpContext.Current.Session["ApexSecurityCodeApproved"] == null
|| !(bool)System.Web.HttpContext.Current.Session["ApexSecurityCodeApproved"]))
     {
          RedirectToRoute("Nop.Plugin.EVO.APEXLogin");
      }

       /// Save information to the database
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.