Home > Net >  C # how to judge the user didn't preach a MVC controller parameters.
C # how to judge the user didn't preach a MVC controller parameters.

Time:04-18

My controller method is as follows, for example, if the front not preach ItemID value, the system will default is 0, this is not what I want results, or do I have to know if there is any front-end ItemID this value, so that I can judge, need not to need to update the field because they do not pass this parameter will be the default value is 0, interferes with I judge the 0 was introduced into the front or the system default,

 public ActionResult UpdateComment (CommentModel C) 
{



Return the Content (new BLL.Com ment (.) UpdateComment (C));
}


The model parameters CommentModel for

 public class CommentModel: PageModel 
{
Public int CommentID {get; set; }
Public int ItemID {get; set; }
Public int ItemType {get; set; }
Public int UserID {get; set; }
Public string Contents {get; set; }
Public string CreateDate {get; set; }


}



CodePudding user response:

This you can consult the front end to, for example if the front not value, let he request send a - 100 or other meaningless value to you,

CodePudding user response:

No assignment will take the default values
  •  Tags:  
  • C#
  • Related