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.
11 лет назад
It's in there just like that?  The RedirectToRoute line is commented out.
11 лет назад
It wasn't doing anything. it didn't redirect to my plugin page.
11 лет назад
Did you set a breakpoint on it and verify that you're actually getting to that line?
11 лет назад
Yeah I did breakpoint. It hits the code but do anything.
and redirects to the page where user supposed to get there.
11 лет назад
filterContext.Result = new RedirectResult("TestLogin");
It gives the following error

"Child actions are not allowed to perform redirect actions"
11 лет назад
Use filterContext.IsChildAction to determine if you should perform the check on the session.
11 лет назад
but how? Then to do what?
11 лет назад
but how? Then to do what?
11 лет назад
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.
11 лет назад
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.