(a) main function {controller} showing the page
Public classUcontroller:controller {// //GET:/u/ PublicActionResult Index () {returnView (); } Public ActionResult Xiugai (string UIDs, string pwd) {bool IsOK = new UBF (). Login (UIDS,PWD); if (IsOK) {//Save status session["UIDs"] = UIDs; Jump interface Return redirecttoaction ("Index", "Home"); } else {return redirecttoaction ("Index"); } } }}
(ii) function {model} modified in the database
Using System.Collections.Generic; using System.Linq; using system.web; namespace Job _ News management. models{ Publicclass UBF { private Newsdbdatacontext context = new Newsdbdatacontext (); public bool Login (string UIDs, string pwd) { var query = context.u.where (p = = P.uids = = UIDs && p.pwd ==PWD); return query. Count () > 0; } }
(iii) display of the interface {Iew}
@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>Index</title> } </div></body>MVC Login Registration Page