How deny access direct URL to my partial views?

北慕城南 提交于 2019-12-21 19:47:23

问题


I have some partial views in my controller. The problem is that users can visualize my partial views if they put in url: (www.mydomain.com/mycontroller/mypartialview). How can I deny direct access... and allow work with partial views only from base view?

Thank's!


回答1:


add [ChildActionOnly] .. like this :

[ChildActionOnly]
        public PartialViewResult List(Model model)
        {...
            return PartialView(model);
        }



回答2:


As Andras says, this would only happen if you have a controller action to return them. I can see that you might have those in place in which case you should add the attribute (filter them) as [ChildActionOnly]



来源:https://stackoverflow.com/questions/10409618/how-deny-access-direct-url-to-my-partial-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!