Asp.net mvc 4 MVC表单post操作在本地工作,但在web服务器上出现错误404

Asp.net mvc 4 MVC表单post操作在本地工作,但在web服务器上出现错误404,asp.net-mvc-4,Asp.net Mvc 4,在我的MVC4应用程序中,我使用以下语法在视图上声明一个表单 @using (Html.BeginForm("Create", "Admin", FormMethod.Post, new { id = "FrmRegistration" })) &以下是表单的操作后方法创建 public ActionResult Create(VirtuOx.Models.Admin.Register AccInfo) { string errMessage = ValidateFi

在我的MVC4应用程序中,我使用以下语法在视图上声明一个表单

@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);
    }

在我的本地机器上,此表单对于表单的post-action方法Create非常有效。但当我在web服务器上部署它时&如果我单击submit按钮,它会给出错误404。我想代码应该没有任何问题,因为它在本地运行良好。

我通过如下更改表单定义来解决问题

@using (Html.BeginForm("Create", "Admin"))
我删除了FormMethod属性&HTML属性对象;这解决了我的问题。
但我不明白这个属性规范如何在共享宿主环境中创建404错误。

呈现表单上的表单内操作属性是什么?对吗?此外,请确保所有文件都已复制到webserver@jim感谢您的重播,所有文件都已正确上载action属性的值为“/Admin/Create”。@jim Hi,你能看看我解决这个问题的方法吗?请简要介绍一下Html.BeginForm()的那些属性是如何产生这样的问题的。让我们看看新旧呈现表单标记之间的区别