0

我正在开发一个MVC中的Web应用程序。 我在数据库中添加了一个链接例如:“www.google.com”,我希望用户在点击后重定向到Google。重定向到链接保存在数据库中的链接

我试过在很多方面,但得到的控制器在地址栏中“例如:http://localhost:/Home/www.google.com

查看代码

<table class="table" style="margin-top:10px;"> 
<tr> 
    <th> 
     Sr. No. 
    </th> 
    <th> 
     Name 
    </th> 
    <th> 
     Details 
    </th> 
    <th> 
     Status 
    </th> 
    <th> 
     Tracking No. 
    </th> 
    <th> 
     Tack Order 
    </th> 
    <th> 
     Ordered On 
    </th> 
</tr> 

@{int row = 0;} @foreach (var item in Model) { if (item.PaymentSuccessfull == true) { 
<tr> 
    <td> 
     @(row += 1) 
    </td> 
    <td> 
     @Html.DisplayFor(modelItem => item.DeliveryDetail.FirstName) 
    </td> 
    <td> 
     <a href="/Home/[email protected]" orderid="1">Order Details</a> 
    </td> 
    <td> 
     @Html.DisplayFor(modelItem => item.Status) 
    </td> 
    <td> 
     @Html.DisplayFor(modelItem => item.TrackingId) 
    </td> 
    <td> 
     //Here I want user to redirect to Google on click 
     <a href="@Html.DisplayFor(modelItem => item.TrackingURL)" target="_blank">Track</a> 
    </td> 
    <td> 
     @Html.DisplayFor(modelItem => item.DateTime) 
    </td> 
</tr> 
} } 

帮助表示赞赏。 在此先感谢。

回答

1

您必须将协议与URL的其余部分一起存储。

这样:

www.google.com

变为:

http://www.google.com

+0

@ scgough ......非常感谢你的帮助..它工作得。 –