![](/img/trans.png)
[英]ASP.NET MVC - how to pass parameters to actions on a different controller
[英]How to pass two parameters to a controller in ASP.NET Core MVC?
我正在尝试将两个参数从 email 链接传递到名为Quotations
的 controller 和方法CreateEditQuotations
。 问题是我只能检索SupplierId
而不是transactionNo
。
我的AppSettings.Json
:
"QuotationSettings": {
"RedirectLink": "https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo={TransactionNo}&?SupplierId={SupplierId}"
},
我想发送到appsettings.json
的 appsettings.json 的测试链接:
string test = "<a href='" + configuration.GetValue<string>("QuotationSettings:RedirectLink") + TransactionNO + configuration.GetValue<string>("QuotationSettings:RedirectLink") + SupplierId + "'>Click here to submit quotation details</a></p>";
这是我得到的不正确的 URL
https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo={TransactionNo}&SupplierId={SupplierId}42dadf63-bc29-4c2d-aa6c-ca669ec0b50e&https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo={TransactionNo}&SupplierId={SupplierId}4
尝试
var test =
configuration
.GetValue<string>("QuotationSettings:RedirectLink")
.Replace("{TransactionNo}", $"{TransactionNO}")
.Replace("{SupplierId}", $"{SupplierId}");
Output
https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo=42dadf63-bc29-4c2d-aa6c-ca669ec0b50e&?SupplierId=4
var redirectLink =
configuration
.GetValue<string>("QuotationSettings:RedirectLink")
.Replace("{TransactionNo}", $"{TransactionNO}")
.Replace("{SupplierId}", $"{SupplierId}");
string test = $"<a href='{redirectLink}'>Click here to submit quotation details</a></p>";
Output
<a href='https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo=42dadf63-bc29-4c2d-aa6c-ca669ec0b50e&?SupplierId=15'>Click here to submit quotation details</a></p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.