在我的应用程序中,我允许用户从我的应用程序重定向到 htttps://www.google.co.in。
为此,我使用了 RouteLink。我知道我们也可以通过 actionLink 来实现。
代码:
@Html.RouteLink("Google",null,"https","www.google.co.in", null, null, new { @style = "color:red" })
生成的 HTML
<a style="color:red" href="https://www.google.co.in/Home/RouteLink">Google</a>
而且我还添加了路由
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "RouteLink",
url: "Home/RouteLink",
defaults: new { Controller = "Home", action = "RouteLink" });
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id =
UrlParameter.Optional }
);
}
所以我的问题是为什么我得到像上面的锚标签?如果 RouteLink 不允许重定向到另一个域,为什么它有接受主机名和协议的重载方法?