我需要创建以下html输出:

<a href="account/register?provider=1">Register</a>

我如何使用ASP.NETMVC6锚标记帮助器来实现这一点?查询字符串部分似乎没有选项.我想用

<a asp-action="Register" asp-controller="Account">Register</a>

但是"提供者=1"应该放在哪里呢?

推荐答案

您是否try 过asp-route-*属性:

<a asp-action="Register" 
   asp-controller="Account"
   asp-route-provider="1">
    Register
</a>

Asp.net相关问答推荐

我们可以在一个网页中使用多个表单吗?

*不*使用 asp.net 会员提供程序是个坏主意吗?

IIS 将旧用户名返回到我的应用程序

Asp.Net 会话在 ashx 文件中为空

如何将 Castle Windsor 与 ASP.Net Web 表单一起使用?

等待本地主机,永远!

将存储过程中 Select 查询的结果返回到列表

asp.net cookie、身份验证和会话超时

缩小失败.返回未缩小的内容

LINQ to Entities 无法识别 MVC 4 中的System.String ToString()方法

在 aspnetcore (netcoreapp1.0) 中替代 System.Web.Security.Membership.GeneratePassword

为 ASP.NET Core MVC 显示 404 Not Found 页面

如何将数据集转换为数据表

如何保护存储在 web.config 中的密码?

IIS 8.0 ASP.NET 和错误 500.19

ASP.NET 按钮重定向到另一个页面

使 WCF Web 服务与 GET 请求一起工作

GridView 按代码隐藏列

IsMobileDevice 是如何工作的?

ASP.NET MVC 5 Web.config:FormsAuthenticationModule或FormsAuthentication