单击链接导致应用程序重新启动

时间:2017-12-17 00:15:30

标签: c# asp.net-mvc

我的注册页面中有两个类似的链接。一个工作,另一个导致应用程序重启。两者完全相同

<div class="col-xs-12 col-md-6" style="top:15px">
    Already have an account? @Html.ActionLink(linkText: "Sign In", actionName: "Login", controllerName: "Account")
</div>

<div class="alert alert-info">
    <strong>Want to be an affiliate?  @Html.ActionLink(linkText: "Join", actionName: "RegisterAffiliate", controllerName: "Account") our affiliation program!</strong>
</div>

在html源代码中我看到了

<div class="col-xs-12 col-md-6" style="top:15px">
    Already have an account? <a href="/Account/Login">Sign In</a>
</div>

<div class="alert alert-info">
    <strong>Want to be an affiliate?  <a href="/Account/RegisterAffiliate">Join</a> our affiliation program!</strong>
</div>

第一个链接正常工作,但是当我点击第二个链接时,会导致应用程序重启。我的意思是我需要Application_Start()

中的Global.asax

两个链接都在同一个form标记

以下是控制器:

[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
    ViewBag.ReturnUrl = returnUrl;
    return View();
}

[AllowAnonymous]
public ActionResult RegisterAffiliate()
{
    RegisterAffiliateViewModel model = new RegisterAffiliateViewModel();
    using (ApplicationDbContext db = new ApplicationDbContext())
    {
        model.Countries = db.Countries.ToList();
    };
    return View(model);
}

当我点击第二个链接时,它甚至没有进入控制器,因为它没有达到我的断点。

我已经挖掘了这个问题好几天了。请帮忙。

1 个答案:

答案 0 :(得分:0)

常见问题您正在制作的Http请求未映射到Controller 把这个标题:

[Route("/Account/RegisterAffiliate")]