Im trying call to an action with Ajax and when i have one item request URL going to be like :
And everything going to work, but when i have more items request URL going to be like :
http://localhost:xxxx/User/getvarelinje?items=AAAADwCZbrc=&items=AAAADwCZ0QU=
And than i will get following error :
The input is not a valid Base64 string, since it contains a character that is not a base 64 character, more than two fill characters, or an invalid character among the fill characters.
This is my Ajax:
<script>
$("#BasketClick").click(function (e) {
e.preventDefault();
var holderHTML = '';
var params = "?";
var seperator = "";
for (var i = 0; i < localStorage.length; i++) {
let key = localStorage.key(i);
params += seperator + "items=" + key;
seperator = "&";
}
$.ajax({
type: "GET",
url: "/User/getvarelinje" + params,
dataType: 'json',
success: function (values) {
console.log(values);
for (var i = 0; i < values.length; i++) {
value = values[i]
console.log(value);
if (value != null) {
holderHTML += '<li>' + value.ItemName + '</li>';
holderHTML += '<li>' + value.Description + '</li>';
}
}
$('#RMABasket').html(holderHTML);
},
})
});
This is my action :
[HttpGet]
public JsonResult getvarelinje(byte[] items) {
var _getItemsLine = db.namespace.Where(s=>s.timestamp == items)
.Select(t=>new GetItemslineVM { Description = t.Description , ItemName = t.No_ })
.ToList();
return Json(_getItemsLine, JsonRequestBehavior.AllowGet);
}
And this is my modal :
public class tablenamespace
{
[Timestamp]
public byte[] timestamp { get; set; }
}
Can anyone please help me :)