Reputation: 571
I need to create a dynamic tag with a url containing JSON values that will be posted to an external payment gateway. Eventually I want something like this:
Pay This Amount
So I figured I would do:
@Html.ActionLink("Pay This Amount", "https://xyz.com/PayNow?paymentData={'StoreID':'1964','Person':{'FirstName':'Joe','MiddleInitial':'A','LastName':'Smith'},'Item':{'1':{'Price':'250','Code':'TUITION'}}}")
But the resulting tag makes the URL in Action/Controller format:
MyWebSite/MyController/https://xyz.com/PayNow?paymentData={'StoreID':'1964','Person':{'FirstName':'Joe','MiddleInitial':'A','LastName':'Smith'},'Item':{'1':{'Price':'250','Code':'TUITION'}}}
...and of course it fails.
I want just a traditional URL not a route. I don't see an overload for a simple URL. Or is there another helper that I can use to create a non-MVC URL?
How do I do this? Thanks!
Thanks.
Upvotes: 0
Views: 152
Reputation: 33071
@Html.ActionLink is used to create an tag to a controller/action in your site. If you just want to create a link to another site just use plain ole HTML:
<a href="https://xyz.com">Pay Now</a>
If you need to use properties from your model you can build the URL in code and then reference that in the tag:
@{
string url = "https://xyz.com?id=" + Model.Id;
}
<a href="@url">Pay Now</a>
or
<a href="https://[email protected]">Pay Now</a>
Upvotes: 2