开发者

Blocking direct URL access to a controller returning a partialview?

If one where to have a controller named UsersCont开发者_Python百科roller with an action like:

public ActionResult ActiveUsers()
{
   IQueryable<TBL_USERS> recentUsers = repo.GetRecentUsers();
   Return PartialView(recentUsers);
}

And this is called via a Html.RenderAction() throughout the ap.

If a user were to navigate to Users/ActiveUsers directly in the address bar the partial view would be rendered in the browser.

Is it possible to block this?


Use ChildActionOnlyAttribute (http://haacked.com/archive/2009/11/18/aspnetmvc2-render-action.aspx)

  [ChildActionOnly]
  public ActionResult Menu() {
    var menu = GetMenuFromSomewhere();
      return PartialView(menu);
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜