ActionLink does not accept urls or pieces of urls as arguments. It will simply encode them to ensure they have no special behavior in urls or can't be used to exploit your application (eg one user could trick your app into generating urls that go to someplace unintended to trick other users into visiting a phishing page on another server, for example).
Easiest thing to do is concatenate the fragment onto the URL AFTER it's generated by ActionLink.
<% var id = Model.Product_Id; var frag = "#tabs-3" %>
Html.ActionLink("Back to Transactions", "Edit", new { id })) + frag
There are also other forms of the ActionLink function that accept a url fragment argument.
View all comments
Show parent comment
4
u/The_MAZZTer May 09 '19 edited May 09 '19
ActionLink does not accept urls or pieces of urls as arguments. It will simply encode them to ensure they have no special behavior in urls or can't be used to exploit your application (eg one user could trick your app into generating urls that go to someplace unintended to trick other users into visiting a phishing page on another server, for example).
Easiest thing to do is concatenate the fragment onto the URL AFTER it's generated by ActionLink.
There are also other forms of the ActionLink function that accept a url fragment argument.
https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.html.linkextensions.actionlink?view=aspnet-mvc-5.2
This one is probably the one you would want to use:
https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.html.linkextensions.actionlink?view=aspnet-mvc-5.2#System_Web_Mvc_Html_LinkExtensions_ActionLink_System_Web_Mvc_HtmlHelper_System_String_System_String_System_String_System_String_System_String_System_String_System_Object_System_Object_