在我的MVC 4应用程序中,我使用以下语法
在视图上声明表单@using (Html.BeginForm("Create", "Admin", FormMethod.Post, new { id = "FrmRegistration" }))
&安培;这是表单的帖子操作方法创建
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);
}
在我的本地计算机上,此表单非常适用于表单的后期操作方法创建。但是当我在Web服务器上部署它时如果我单击“提交”按钮,则会给出错误404.我想代码应该没有任何问题,因为它在本地工作正常。
答案 0 :(得分:0)
我设法通过更改表单定义来解决问题,如下所示
@using (Html.BeginForm("Create", "Admin"))
我删除了FormMethod属性& HTML属性对象;这解决了我的问题。 但我不明白这个属性规范如何在共享托管环境中创建404错误。