在我的 MVC 4 应用程序中,我正在使用以下语法声明一个表单
@using (Html.BeginForm("Create", "Admin", FormMethod.Post, new { id = "FrmRegistration" }))
& 这里是表单的 post action 方法Create
public ActionResult Create(VirtuOx.Models.Admin.Register AccInfo)
{
string errMessage = ValidateFields(AccInfo);
ModelState.Clear();
if (errMessage == "")
{
byte[] unsaltedPassword = Signin.StrToByteArray(AccInfo.Password);
byte[] saltValue;
byte[] saltedPassword = Signin.GeneratePassword(unsaltedPassword, out saltValue);
//pharmacy superuser password
byte[] PHARM_unsaltedPassword = Signin.StrToByteArray(AccInfo.SuperUserPassword ?? "");
byte[] PHARM_saltValue;
byte[] PHARM_saltedPassword = Signin.GeneratePassword(PHARM_unsaltedPassword, out PHARM_saltValue);
string _membershipexpirationdate = (string)DB.ExecuteScalar("ConnectionString", "pc_GetConfigurationValue", new SqlParameter("@Code", "MembershipExpirationDate"));
VirtuOx.Models.Customer.Register custRegister = new VirtuOx.Models.Customer.Register(AccInfo.VendorAccountID, AccInfo.UserName, Convert.ToBase64String(saltedPassword),
Convert.ToBase64String(saltValue), Guid.NewGuid().ToString(), Convert.ToInt32(AccInfo.MembershipType),
_membershipexpirationdate, AccInfo.FirstName, AccInfo.LastName, AccInfo.CompanyName, AccInfo.Email,
AccInfo.Street, AccInfo.City, AccInfo.State, "US", AccInfo.PostalCode,
AccInfo.WorkPhone ?? "", AccInfo.Fax ?? "", AccInfo.ReportFax ?? "", AccInfo.Cell ?? "", AccInfo.CustomerRole,
AccInfo.PhysicianID ?? 0, AccInfo.HierarchyLevelID ?? 0, Convert.ToInt32(AccInfo.EnableHST),
Convert.ToInt32(AccInfo.EnablePST), Convert.ToInt32(AccInfo.EnableHSTRecommendations),
Convert.ToInt32(AccInfo.EnableDocumentationEmail), 1, 1, 1, 1, Convert.ToInt32(AccInfo.EnableWireless),
(AccInfo.CustomerRole != "12" ? 0 : Convert.ToInt32(AccInfo.CompanyID)),
Convert.ToBase64String(PHARM_saltedPassword), Convert.ToBase64String(PHARM_saltValue),
AccInfo.ParentID ?? 0);
WebProfile response = custRegister.RegisterCustomer();
if (response.Type == "S")
{
ViewBag.SuccessMessage = response.Text;
ModelState.Clear();
}
else
ModelState.AddModelError("ExpAccount", response.Text);
}
else
{
ModelState.AddModelError("Exception", errMessage);
}
AccInfo.StateList = Common.GetStates();
AccInfo.RoleList = Common.GetRoleTypes();
AccInfo.CompanyList = Common.GetCustomerBranchList();
AccInfo.ParentList = Common.GetReferenceList("PARENTID");
AccInfo.HierarchyLevelList = Common.GetReferenceList("HIERARCHY");
return View("~/Views/Admin/Register.cshtml", AccInfo);
}
在我的本地机器上,此表单非常适合表单的后操作方法Create。但是当我将它部署在网络服务器上时,如果我单击提交按钮,它会给我错误 404。我想代码应该没有任何问题,因为它在本地工作正常。