We all are aware that when we take any model from view(user input) into the controller , we always tend to
But the same is not applicable when we are doing same in class file which does not inherit controller class.
use ModelState.IsValid to check if model is valid , then only we will proceed for further processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
[ValidateAntiForgeryToken] | |
public ViewResult Share( model_document param_model_document ) | |
{ | |
// VALIDATE THE MODEL | |
if(ModelState.IsValid) { | |
// DO THE DESIRED TASK | |
} | |
return View(); | |
} |
But the same is not applicable when we are doing same in class file which does not inherit controller class.