In MVC, where is the right place to place the authorization code?

In MVC, where is the right place to enter the authorization code?
Controller?
Model?
From point of view?

All over the place?

+5
source share
5 answers

, , . ( ) AuthorizeAttribute - , . - - , ViewData. , , , .

+3

, - . - , , .

+1

!

. .

, , - , .

: if ( )

+1

M, V c, C . , , - . , .

MVC - " ", . . ""; . , , , . ?

0

Model.

The controller is designed to switch in different ways. View is for ... viewing only.

Thus, you must make all authorization codes at the model level. Ideally, everything will work fine. If not, the controller will transfer the user to the corresponding login window.

0
source

All Articles