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 ......非常感謝你的幫助..它工作得。 –