Sunday, 15 July 2012

c# - unable to modify MVC 4 bult-in login controller -



c# - unable to modify MVC 4 bult-in login controller -

i'm using mvc4 application built-in business relationship registration , login controllers(and respective models). i've own method deleting accounts. want set check in standard login controller, checks if i've deleted business relationship myself , redirect person informative page.

however, when controller gets called passes line of code , still logs user in. i've checked db. user has 0 set isactive(that lists accounts "active" , "inactive") value , should redirected. logs in line of code doesn't exist...

this code in controller:

[httppost] [allowanonymous] [validateantiforgerytoken] public actionresult login(loginmodel model, string returnurl) { if (workerdal.isactive(model.username)) redirecttoaction("displaydeletedusermessage", "home"); //my redirect code if (modelstate.isvalid && websecurity.login(model.username, model.password, persistcookie: model.rememberme)) { homecoming redirecttolocal(returnurl); } // if got far, failed, redisplay form modelstate.addmodelerror("", "the user name or password provided incorrect."); homecoming view(model); }

the code dal class:

public static bool isactive(string _username) { timetrackerentities db = new timetrackerentities(); foreach (worker worker in db.workers) { if (worker.username == _username) { if (worker.isactive == 1) homecoming true; if (worker.isactive == 0) homecoming false; } } homecoming true; }

am using wrong action user redirect? or obvious that? i'm lost...

edit - eric j. , jonathon page code working. give thanks both! how can note both of comments right answer?

you missing homecoming keyword:

redirecttoaction("displaydeletedusermessage", "home"); //my redirect code

should read:

return redirecttoaction("displaydeletedusermessage", "home"); //my redirect code

c# asp.net-mvc asp.net-mvc-4

No comments:

Post a Comment