I ad trying to pass parameters to call the following C# method
public ActionResult GenerateInvoicePDFByInvoiceNum(string id,string apikey)
{
IInvoiceRepository rep = db.GetInvoiceRepository();
//
var api = Guid.Parse(apikey);
Invoice invoice = rep.GetByExpression(i => i.InvoiceNo.Equals(id) && i.Visit.Branch.Practice.APIKey.ToString().Equals(apikey)).FirstOrDefault();
if (invoice==null)
{
return HttpNotFound();
}
//return new Rotativa.ActionAsPdf("PrintInvoice", new { id = invoice.Id })
//{
// //CustomSwitches = "--load-error-handling ignore "
// CustomSwitches = "--disable-javascript"
//};
return RedirectToAction("GenerateInvoicePDF", new { id = invoice.Hash });
}
From the browser I am trying to call it with a call like this which worked when I had only one parameter, but I don't know how to change those to pass the second parameter
http://foobar.n.co.za/Newlook/PrintInvoice/GenerateInvoicePDFByInvoiceNum/72341d
Thanks
CodePudding user response:
On your url: http://foobar.n.co.za/Newlook/PrintInvoice/GenerateInvoicePDFByInvoiceNum/72341d
"/72341d" represents an optional parameter.
Try to pass a query string. To do that, you need to specify the parameter name and value you want to pass.
CodePudding user response:
This is how you pass parameters by url:
CodePudding user response:
You can pass multiple parameters as "?param1=value1¶m2=value2"
http://foobar.n.co.za/Newlook/PrintInvoice/GenerateInvoicePDFByInvoiceNum?id=1&1pikey=2