I have the following block of code that creates an Action Link for a company.
Html.ActionLink(Html.Encode开发者_如何学编程(currentCompany.GetDisplayName()), "CompanyFactsheet", "Company",
                                                       new {friendlyURL = currentCompany.FriendlyURL.ToLower()}, null)%>
Some of the company names contain '&', and this is being rendered as &
Is there a way that I can Html.Encode the company names, but still keep the & symbol as it's supposed to look, rather than &?
It seems like you don't need to encode when using ActionLink helper method. It encodes internally:
How do I bypass the HTML encoding when using Html.ActionLink in Mvc?
Double check the markup that is getting generated. The only way that the & should be showing on the page is if you're double encoding the ampersand character (so the source of the page would be showing &).
This could be caused by either storing the character already HTML encoded or you're using <%: (which HTML encodes everything for you automatically) instead of <%= in your View.
Replace & to some other charachter before saving them, and replace them back AFTER encoding (using jquery most likely)... I know it sounds like overkill, but if you really need the Html.Encode (or <%:, or @ in Razor), this is the best way IMHO....
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论