繁体   English   中英

实体框架和ASP.NET MVC:无法从另一个控制器进入我控制器上的[HttpPost]

[英]Entity Framework & ASP.NET MVC: can't get to the [HttpPost] on my controller from another one

我正在尝试将用户从SolicitantesController上的该视图重定向到Create of ExpedientesController上的视图:

@model Entrega02Programacion03.Models.Solicitante

@{
    ViewBag.Title = "InformeSolicitante";
}

<h2>InformeSolicitante</h2>

<div>
    <h4>Solicitante</h4>
    <hr />
    <dl class="dl-horizontal">
       <dd>Cedula:  @ViewBag.Cedula </dd> 
      <dd> Nombre: @ViewBag.Nombre</dd>
       <dd>Apellido: @ViewBag.Apellido</dd>
       <dd>Email:  @ViewBag.Email</dd>
       <dd>Tel: @ViewBag.tel</dd>
    </dl>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Crear Expediente" class="btn btn-default" />
        </div>
    </div>
</div>

这是solicitantesController上的帖子,但是我无法按按钮Crear Expediente到达那里,关于我可能做错了什么的任何想法? 谢谢

[HttpPost]
public ActionResult InformeSolicitantes()
{
     return RedirectToAction("Expedientes", "Create");
}

我建议两种解决方案来解决它:

1)用InformeSolicitantes操作网址替换带有锚链接的提交html控件 ,并删除[HttpPost]

例如替换

<input type="submit" value="Crear Expediente" class="btn btn-default" />

<a class="btn btn-default" href="action path/name"></a>

然后删除

[HttpPost]

2)将输入控件置于表单控件中,并设置表单动作和控制器以击中InformeSolicitantes动作。

例如替换

<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <input type="submit" value="Crear Expediente" class="btn btn-default" />
    </div>
</div>

<form action="action path/name" method="post"><div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <input type="submit" value="Crear Expediente" class="btn btn-default" />
    </div>
</div></form>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM