Hi All!
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?
If these actions are being used as child actions with Html.Action() then you can put [ChildActionOnly] on the action methods to prevent them from being accessed directly from the browser.
vladislav89
0 Points
1 Post
How deny access direct URL to my partial views?
May 02, 2012 07:39 AM|LINK
Hi All!
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!
ignatandrei
All-Star
134527 Points
21579 Posts
Moderator
MVP
Re: How deny access direct URL to my partial views?
May 02, 2012 07:47 AM|LINK
MVC denies direct access to your views (that ends either in aspx/ascx, either in cshtml/ vbhtml)
More, this
www.mydomain.com/mycontroller/mypartialview
is an ACTION, not a View ( even partial).
More, it is your code - MVC does not make any action WITHOUT implementing( look at default template)
So delete the action that renders the partial view.
What's the code in the base view?
BrockAllen
All-Star
27438 Points
4893 Posts
MVP
Re: How deny access direct URL to my partial views?
May 02, 2012 01:35 PM|LINK
If these actions are being used as child actions with Html.Action() then you can put [ChildActionOnly] on the action methods to prevent them from being accessed directly from the browser.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/