我正在尝试通过从Byte[]
中的View转换为控制器来发送@Html.ActionLink
。 Evey时间点击ActionLink
它会抛出异常。我在这里附上代码。
http://localhost:55253/Member/Create?customerContactNumber=0439349
&committeeId=AAAAAAAADLc%3D
@using VolunteerPoints.BootstrapSupport
@model Tuple<VolunteerPoints.Models.Contact, IEnumerable<VolunteerPoints.Data.Committee>>
@{
ViewBag.Title = "SearchResults";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Activity Search Results</h2>
<table id="Activitieslist" class="table table-striped table-bordered table-hover .table-condensed">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Item2.GetEnumerator().Current.Committee_Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Item2.GetEnumerator().Current.Committee_Type)
</th>
<th></th>
</tr>
</thead>
@foreach (var model in Model.Item2)
{
<tr>
<td>
@Html.DisplayFor(modelItem => model.Committee_Name)
</td>
<td>
@Html.DisplayFor(modelItem => model.Committee_Type)
</td>
<td>
<div>
<div>
@Html.ActionLink("Select", "Create","Member", new
{customerContactNumber = Model.Item1.Number, committeeId =
Convert.ToBase64String(model.Committee_Id) }, new { @class = "btn btn-primary" })
</div>
</div>
</td>
</tr>
}
</table>
@section Scripts {
@Styles.Render("~/Content/DataTables/css")
@Scripts.Render("~/bundles/DataTables")
<script type="text/JavaScript">
$(document).ready(function () {
$('#Activitieslist').dataTable({
"bSort": true,
"bPaginate": false,
"bAutoWidth": false,
});
});
</script>
}
答案 0 :(得分:2)
这部分网址:
AAAAAAAADLc%3D
应解码为
AAAAAAAADLc=
...此时长度是4的倍数,最后有完全合理的填充。
所以我怀疑问题是如何/是否执行解码。
(作为旁注:byte[]
是一个非常不寻常的ID代表。你真的需要这样做吗?)
答案 1 :(得分:1)
尝试更改代码部分:
committeeId = Convert.ToBase64String(model.Committee_Id)
要
committeeId = HttpServerUtility.UrlTokenEncode(model.Committee_Id)
这将提供更友好的URL加密字符串,以避免URL中可能导致错误的字符。
希望这能帮助你James123;