I have a Razor view, which writes a javascript object:
var invoices = [
@foreach (var invoice in Model.PartnerInvoices)
{
<text>[{ 'orderid': "@invoice.Id", 'invoiceDate': "@invoice.InvoiceDate.ToString("dd-MM-yyyy")", 'customerName': "@invoice.CustomerName", 'customerCountry': "@invoice.CustomerCountry", 'amount': "@invoice.Amount", 'pdfLink': "@invoice.PdfUrl", 'status': "@(invoice.Status?"Sent":"Not sent")", 'accessId': "@Model.AccessToken", 'downloadPdfLink': "@invoice.DownloadPdfLink" }],</text>
}
];
The value of @invoice.DownloadPdfLink
is the following, when looking at in controller:
/partner/GetEconomicInvoice?pdfUrl=https://restapi.e-conomic.com/invoices/booked/20245/pdf&token=2IuGl4j2sGKNWw1
Notice that between pdf and token, there is a single ampersand (&).
However, when I look at the rendered source code in my browser, I get the following output. The important difference is extra amp;
that is being added after my ampersand.
var invoices = [
[{ 'orderid': "20244", 'invoiceDate': "15-06-2014", 'customerName': "LetterAmazer IvS", 'customerCountry': "Denmark", 'amount': "1117,00", 'pdfLink': "https://restapi.e-conomic.com/invoices/booked/20244/pdf", 'status': "Not sent", 'accessId': "D-ctbWsI6dSw1", 'downloadPdfLink': "/partner/GetEconomicInvoice?pdfUrl=https://restapi.e-conomic.com/invoices/booked/20244/pdf&token=D-ctbWsI6dSw1" }],
[{ 'orderid': "20245", 'invoiceDate': "15-06-2014", 'customerName': "Holtron v. Ib Holdgaard", 'customerCountry': "Denmark", 'amount': "219,00", 'pdfLink': "https://restapi.e-conomic.com/invoices/booked/20245/pdf", 'status': "Not sent", 'accessId': "D-ctbWsI6dSw1", 'downloadPdfLink': "/partner/GetEconomicInvoice?pdfUrl=https://restapi.e-conomic.com/invoices/booked/20245/pdf&token=D-ctbWsI6dSw1" }],
[{ 'orderid': "20243", 'invoiceDate': "01-06-2014", 'customerName': "Datahouse Ltd.", 'customerCountry': "Data Country", 'amount': "767,00", 'pdfLink': "https://restapi.e-conomic.com/invoices/booked/20243/pdf", 'status': "Sent", 'accessId': "D-ctbWsI6dSw1", 'downloadPdfLink': "/partner/GetEconomicInvoice?pdfUrl=https://restapi.e-conomic.com/invoices/booked/20243/pdf&token=D-ctbWsI6dSw1" }],
];
How on earth is this extra amp; being added? And how to solve it?
I have tried to UrlEncode/UrlDecode without luck. The amperstand is still being added.