I have a MVC application where i have used jquery for service calls and displaying in the views. I am planning to add call to authentication in the layout page, but if user directly calls the partial view page, authentication will not call at all.
Asked
Active
Viewed 64 times
1
-
Why would a user call the Partial View? Are you using the User.Identity Model? – Jamie Rees Jul 28 '15 at 16:06
-
Nope. I am not using User.Identity Model. But i am not doing anything to prevent the user to call the partial views. I should be prevent user to call the partial views? I am new to MVC. Kindly help. – user5050407 Jul 28 '15 at 16:09
-
How are you making sure your user is Authenticated? – Jamie Rees Jul 28 '15 at 16:09
-
Passing the userid to a authentication REST service and ensure the user is a valid user. – user5050407 Jul 28 '15 at 16:10
-
And then? Are you not storing if the user is authenticated or are you issuing the request every time? – Jamie Rees Jul 28 '15 at 16:11
-
Check this out: https://msdn.microsoft.com/en-us/library/system.web.mvc.actionfilterattribute(v=vs.118).aspx – NoAlias Jul 28 '15 at 16:11
-
for example, if a user very first time go to the application via a partial view page, how my authentication will get trigger? – user5050407 Jul 28 '15 at 16:12
1 Answers
1
I am not totally understanding what you are trying to do with the Layout file, but you can decorate your Action methods with [ChildActionOnly]
to prevent the user from being able to navigate to them directly. See: Using ChildActionOnly in MVC

Community
- 1
- 1

stephen.vakil
- 3,492
- 1
- 18
- 23