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

问题描述 投票:0回答:1

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

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

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

几天来我一直在研究这个问题。请帮忙。

c# asp.net-mvc
1个回答
0
投票

常见问题您正在制作的Http请求未映射到Controller放置此标头:

[Route("/Account/RegisterAffiliate")] 
© www.soinside.com 2019 - 2024. All rights reserved.