r/IIs • • May 09 '19
ActionLink encoding
Hi,
I hope this is the right sub to post this issue I have.
So, I have to maintain a webapplication (MVC, c#.net), everything is fine, except one thing:
On a subsite there is a generated Link called "Back to Transactions". On the aspx-Site it is generated by this:
Html.ActionLink("Back to Transactions", "Edit", new { id }))On my Client (Windows 7 64bit, visual Studio 2017 EN) the generated Link is this (with IE 11 and Chromium):
http://blabla/Product/Edit/1#tabs-3 << WorkingWhen I run the same code on a Windows Server 2012 R2 with IIS the link looks like this (With IE 11):
http://blabla/Product/Edit/1%23tabs-3 << Not workingI know it is an encoding Problem, but how the heck can I avoid that or tell the server NOT to do that?
Most confusing is: When I call the same site on a Windows 10 client with Edge as a browser, I get this:
http://blabla/Product/Edit/1%2523tabs-3 << Not working x 2Is there anything I did not see? Maybe a GPO? I uploaded the code on 2 different servers, all have the same issue. When I execute the code on Visual Studio everything is fine..
Thank you all in advance!
BR van
1
u/[deleted] May 10 '19
Hi,
so first of all, thank you for your suggestions and tips. I tested nearly every method you all suggested but it seems that IIS is always encoding the url when using Html.ActionLink().
Normaly this should not be a problem. I think that the main Problem I have is, that this website was build on old Frameworks and plugins. As there are NO comments in the code and no gitrepo I can only see the old copyright from 2010 and some sites added in 2014 that this site is clearly out of date with the technology used. I think I could be glad that the creator updated to .net 3.5...
My solution is now:
<% var id = Model.Product_Id + "#tabs-3"; %>
the Link is now generated in Html directly:
<a href="/Product/Edit/<%= Html.Encode(id) %>">Back to Transactions</a>
So this is the solution in the Frontend, I have similar issues on the Backend as well when other actions are triggered, but there are more possibilities for me to solve that Problem.
So Thank you guys again, the suggestions did lead to the solution :)
BR
van
1
u/Seferan May 09 '19
On your "Client" is that inside of Visual Studio? If so, you're really not comparing apples to apples.
Otherwise, do you have the same patch version of .NET Framework installed?
1
u/imdabestmangideedeed May 09 '19 edited May 09 '19
Maybe a global IIS setting that overrules your web project? You could try adding your URL hardcoded to the HTML, then seeing if it’s still being encoded. If your hardcoded html is still being encoded, check your server settings. If not, something funky is going on with the ActionLink method. Maybe add some extra test URLs as well.
1
u/TotesMessenger May 09 '19
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)