How to pass two parameters to a controller in ASP.NET Core MVC?

Zidane

I am trying to pass two parameters from an email link to a controller named Quotations and to method CreateEditQuotations. The problem is I am only able to retrieve the SupplierId and not the transactionNo.

My AppSettings.Json:

"QuotationSettings": {
    "RedirectLink": "https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo={TransactionNo}&?SupplierId={SupplierId}"
},

The test link from appsettings.json that I want to send to email:

string test = "<a href='" + configuration.GetValue<string>("QuotationSettings:RedirectLink") + TransactionNO + configuration.GetValue<string>("QuotationSettings:RedirectLink") + SupplierId + "'>Click here to submit quotation details</a></p>";

And this is the incorrect URL that I am getting

https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo={TransactionNo}&SupplierId={SupplierId}42dadf63-bc29-4c2d-aa6c-ca669ec0b50e&https://localhost:44334/Quotations/CreateEditQuotations/?TransactionNo={TransactionNo}&SupplierId={SupplierId}4
Nafis Islam

Try

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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to I pass multiple parameters from a form to a controller in Asp.net MVC core?

From Dev

How to send two arrays as POST request parameters from AJAX to MVC controller (ASP .NET Core 3.1 razor)?

From Dev

How to pass two Values from specific row in view to Controller asp.net core mvc?

From Dev

How do I pass DateTime parameters from View to Controller in ASP.net MVC5?

From Dev

With same parameters and methods name, how can the controller finds which one to be invoked in ASP.NET core MVC

From Dev

How to pass AppSettings from ASP.NET Core MVC Controller to ReactJS / Redux ClientApp?

From Dev

How to pass a value from foreach loop in the view to the controller in ASP.NET Core MVC?

From Dev

ASP.NET Core MVC | how to pass a value between controller methods

From Dev

How can I pass the datatable parameter to my controller for my crystal report for saving file name with parameters of the table in ASP.Net MVC?

From

ASP.Net MVC How to pass data from view to controller

From Dev

How to pass data from Controller to WebForm in ASP.NET MVC?

From Dev

How to pass <div> value to another Controller in ASP.Net MVC?

From Dev

How to pass value of particular row to controller method in asp .net mvc

From Dev

How to pass a complex model back to the controller in asp.net mvc

From Dev

How to Pass value from view to another controller in MVC ASP .NET

From Dev

How to pass id to MVC controller with Jquery and ajax [ASP.NET]

From Dev

How to pass parameter to View Component via Asp .Net Core controller

From Dev

Asp.Net core ActionFilter - how to pass varying number of parameters

From Dev

How to pass parameters to Ajax to asp.Net core

From Dev

How to navigate to an ASP.NET Core MVC controller in Blazor app?

From Dev

How can I redirect with a controller with id in ASP .NET MVC CORE

From Dev

Asp Net core Controller URL parameters

From Dev

How to pass an object to an action method in ASP.NET Core MVC

From Dev

Pass multiple parameters from ajax post to asp.net mvc controller

From Dev

Sessionless controller in Asp.Net Mvc Core

From Dev

ASP.NET Core MVC Subaction in a controller

From Dev

JQuery Ajax call not passing parameters to `Controller Method` in ASP.NET Core MVC?

From Dev

Asp.net core mvc ajax post to controller with multiple parameters return bad request

From Dev

How do I pass data from an ASP.NET WebAPI ApiController to an ASP.NET MVC Controller?

Related Related

  1. 1

    How to I pass multiple parameters from a form to a controller in Asp.net MVC core?

  2. 2

    How to send two arrays as POST request parameters from AJAX to MVC controller (ASP .NET Core 3.1 razor)?

  3. 3

    How to pass two Values from specific row in view to Controller asp.net core mvc?

  4. 4

    How do I pass DateTime parameters from View to Controller in ASP.net MVC5?

  5. 5

    With same parameters and methods name, how can the controller finds which one to be invoked in ASP.NET core MVC

  6. 6

    How to pass AppSettings from ASP.NET Core MVC Controller to ReactJS / Redux ClientApp?

  7. 7

    How to pass a value from foreach loop in the view to the controller in ASP.NET Core MVC?

  8. 8

    ASP.NET Core MVC | how to pass a value between controller methods

  9. 9

    How can I pass the datatable parameter to my controller for my crystal report for saving file name with parameters of the table in ASP.Net MVC?

  10. 10

    ASP.Net MVC How to pass data from view to controller

  11. 11

    How to pass data from Controller to WebForm in ASP.NET MVC?

  12. 12

    How to pass <div> value to another Controller in ASP.Net MVC?

  13. 13

    How to pass value of particular row to controller method in asp .net mvc

  14. 14

    How to pass a complex model back to the controller in asp.net mvc

  15. 15

    How to Pass value from view to another controller in MVC ASP .NET

  16. 16

    How to pass id to MVC controller with Jquery and ajax [ASP.NET]

  17. 17

    How to pass parameter to View Component via Asp .Net Core controller

  18. 18

    Asp.Net core ActionFilter - how to pass varying number of parameters

  19. 19

    How to pass parameters to Ajax to asp.Net core

  20. 20

    How to navigate to an ASP.NET Core MVC controller in Blazor app?

  21. 21

    How can I redirect with a controller with id in ASP .NET MVC CORE

  22. 22

    Asp Net core Controller URL parameters

  23. 23

    How to pass an object to an action method in ASP.NET Core MVC

  24. 24

    Pass multiple parameters from ajax post to asp.net mvc controller

  25. 25

    Sessionless controller in Asp.Net Mvc Core

  26. 26

    ASP.NET Core MVC Subaction in a controller

  27. 27

    JQuery Ajax call not passing parameters to `Controller Method` in ASP.NET Core MVC?

  28. 28

    Asp.net core mvc ajax post to controller with multiple parameters return bad request

  29. 29

    How do I pass data from an ASP.NET WebAPI ApiController to an ASP.NET MVC Controller?

HotTag

Archive