ASP.NET Core生成超链接
引用自:
1、传统方式
- 第一种:@Html.ActionLink("Register", "Register", "Account")
- 第二种:"@Url.Action("Register", "Account")">Register
生成的Html代码
"/Product/Display/1">View Detailsa>
4、通过路由名称指定
- routes.MapRoute(
- name: "login",
- template: "login",
- defaults: new { controller = "Account", action = "Login" });
比如是上面这个路由
- <a asp-route="login">Logina>
通过asp-route指定就可以了
"https://aspecificdomain.com/Account/Register#fragment">Registera>
6、如果你要指定网站当前的域名
- @Html.ActionLink("Register", "Register", "Account", "https", null, null, null, null)
7、asp.net core中新增的方法
- <a asp-controller="Account"
- asp-action="Register"
- asp-protocol="https"
- asp-host="asepecificdomain.com"
- asp-fragment="fragment">Registera>
- <a asp-controller="Account"
- asp-action="Register"
- asp-protocol="https">Registera>