asp.net mvc 4 - MVC Form action method gets overwritten -
i have following razor form:
@model @using (html.beginform("resetpassword", "user", formmethod.post, new { @class = "form-horizontal", role = "form" })) { @html.antiforgerytoken() @html.hidden("guid", viewdata["guid"]) ....ect contains model , 1 hidden field
when hit page must pass guid following way:
user/resetpassword/8c5f38cc-c8db-46b4-80f5-169699d8a583
i hit action controller expected:
public actionresult resetpassword(string id) { viewbag.title = @ddhelper.getcontent("user_password_reset_new") + " " + @ddhelper.getcontent("slogan") + " " + @ddhelper.getmeta("sitename"); if (id != null) { guid pwid = new guid(); if (guid.tryparse(id, out pwid)) { if (usermanager.getresetpassworduser(pwid) != null) { viewdata["guid"] = id; return view(new models.user()); } } } return view(); }
now when @ html razor produced see:
<form action="/user/resetpassword/8c5f38cc-c8db-46b4-80f5-169699d8a583" class="form-horizontal" method="post" role="form">
when post form want hit action:
[httppost] [validateantiforgerytoken] public actionresult resetpassword(models.user pwuser) { string guid = request["guid"]; string password = pwuser.password; guid pwid = new guid(); if (guid.tryparse(guid, out pwid)) { usermanager.resetuserpassword(password,pwid); return redirecttoaction("logon"); } return view(guid); }
now when post form hit cshtml again , not hitting action because action
/user/resetpassword/8c5f38cc-c8db-46b4-80f5-169699d8a583
does not exsist , everytime hits page guid different. how can tell html.beginform not write parameters in action name? , why razor behaving this?
Comments
Post a Comment