当我在 MVC 中 运行 项目时,href 的 link 发生了变化
A href's link is changed when I run the project in MVC
我正在尝试使用以下代码在我的项目中创建一个 link:
<body>
<ul>
@foreach (Menu menu in ViewBag.menu)
{
<li>
<a href="www.google.com">google</a>
</li>
}
</ul>
</body>
但是当我在mvc中运行我的项目时,这段代码的link变成了http://localhost:2321/www.google.com
。
那么我怎样才能删除这部分http://localhost:2321
?
只需指定完整的 link,带有协议;否则它被解释为好像您正在尝试访问本地对象(通过相对路径):
<a href="http://www.google.com">google</a>
我正在尝试使用以下代码在我的项目中创建一个 link:
<body>
<ul>
@foreach (Menu menu in ViewBag.menu)
{
<li>
<a href="www.google.com">google</a>
</li>
}
</ul>
</body>
但是当我在mvc中运行我的项目时,这段代码的link变成了http://localhost:2321/www.google.com
。
那么我怎样才能删除这部分http://localhost:2321
?
只需指定完整的 link,带有协议;否则它被解释为好像您正在尝试访问本地对象(通过相对路径):
<a href="http://www.google.com">google</a>