小编Ann*_*apa的帖子

MVC ASP.NET没有为此对象定义的无参数构造函数

当我单击"提交"以创建帐户时,将显示以下错误.我无法找到它为什么会出现以下错误.我也尝试使用断点和调试,但它没用

没有为此对象定义的无参数构造函数.

描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.

异常详细信息:System.MissingMethodException:没有为此对象定义的无参数构造函数.

来源错误:

在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.

AccountController.cs

    [HandleError]
        public ActionResult CreateNewFixedBankAccount()
        {
            ViewBag.AccountFromList = new SelectList(
           ManageAccount.Instance.GetAccounts(), "accountID", "name");
            ViewBag.AccountTypes = new SelectList(ManageAccountType.Instance.GetNonFixedTypes(), "id", "type");
            ViewBag.Durations = new SelectList(ManageDuration.Instance.GetAllDurations(), "id", "duration1");


            ViewBag.Currencies = new SelectList(ManageCurrency.Instance.getCurrencies(), "id", "symbol");
            return View();


        }

        //
        // POST: /Account/CreateNewFixedBankAccount
        [HttpPost]
        [HandleError]
        public ActionResult CreateNewFixedBankAccount(ViewModel.NewAccountViewModel model, string username)
        {

            return View();
        }

___________________________________________________________________________________________
Run Code Online (Sandbox Code Playgroud)

CreateNewFixedBankAccount.cshtml 下面的提交按钮给出了错误

    @model internetBankingApplication.ViewModel.NewFixedAccountViewModel    
    @{
        ViewBag.Title = "CreateNewFixedBankAccount";
    }


    @using (Html.BeginForm())
    {

        ViewBag.Title = "Create";
        Layout = "~/Views/Shared/_Layout.cshtml";
        <fieldset>
            <legend>Fixed Account Details</legend>

            <div …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc viewmodel asp.net-mvc-3 asp.net-mvc-viewmodel

3
推荐指数
1
解决办法
2万
查看次数