小编Mr.*_*Ken的帖子

AND - 在SQL Server中

我的代码为:

Select 
    ProductId, ProductCode, Color
From 
    dbo.Product 
Where 
   @Productname = ProductName 
   and ( Color != 'Orange' or Color != 'Green') 
Run Code Online (Sandbox Code Playgroud)

结果包括颜色为"橙色","绿色"的产品:

    1   prod0001   Orange
    2   prod0002   Blue
    3   prod0003   Yellow
    4   prod0004   Green
    5   prod0005   Orange
    6   prod0006   Blue
    7   prod0007   Yellow
    8   prod0008   Green
Run Code Online (Sandbox Code Playgroud)

我希望得到颜色的产品!=绿色或!=橙色.

sql sql-server stored-procedures

1
推荐指数
1
解决办法
50
查看次数

不允许子操作执行重定向操作 - MVC

我有一个_layout加载菜单:

...
@Html.Action("MenuRole","Menu")
...
Run Code Online (Sandbox Code Playgroud)

在Action MenuRole我检查与Action Filter的会话:

[CheckSession]
[ChildActionOnly]
public ActionResult MenuRole()
{
    ....
    return PartialView("_LoadMenu",menuModel);
//_LoadMenu is partial view to show menurole
}
Run Code Online (Sandbox Code Playgroud)

并在Action Filter中:

public class CheckSession : ActionFilterAttribute, IActionFilter
    {

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var ctx = filterContext.HttpContext;

            //if Session == null => Login page
            if (ctx.Session["Username"] == null)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { action = "Index", controller = "Login" }));

            }

            base.OnActionExecuting(filterContext);
        }
    }
Run Code Online (Sandbox Code Playgroud)

当会话超时时,_layout在@ Html.Action("MenuRole","Menu")中显示错误:不允许子操作执行重定向操作

asp.net-mvc custom-action-filter action-filter asp.net-mvc-3 asp.net-mvc-4

1
推荐指数
1
解决办法
2578
查看次数