3

What is the correct way to restrict or allow access to a controller based on some criteria. I am having hard time to wrap my head around it...

For Example, if i say somewhere (in db or some other persistence) that 'LocationA' can be served with 'ActionController', 'ReviewController' & 'PlacementController'. Then have to see that where 'UserA' has the right to view or reach to 'PlacementController' or any other Controller? In other case it might be 'LocationB' can be served with 'ActionController' & 'ReviewController' only and then have to check if 'UserB' can view/reach to these controller?

What is the best approach for this or How i will implement this?

I am using MVC4 (can move to MVC5) if it will help..

Any guidance will be appreciated

Angloos
  • 755
  • 5
  • 11

1 Answers1

0

One easy way to implement this would be using Session, set some specific value in the session according to the page you can navigate to from there.

Lets say you can go to A; from B,C & D. So you add a value to Session in these 3 actions that you can validate at the beginning of A. From C, you can move to B. In such case, you can add values for B & A at C action, so both navigation can be successful.

This is not a elegant way though, but might be easier to implement.

Hope it helps.

SamGhatak
  • 1,487
  • 1
  • 16
  • 27