Search code examples
c#xmlasp.net-mvccastle-windsorxdt-transform

MVC HTML ActionLink inserting a lot of %20 in the URL


I am using C# ASP MVC3 and I am making a generated menu with parameters passed through castle windsor.

When I was developing and tested locally, the urls generated from this code were fine:

  @foreach(var menuItem in Model.MenuItems)
        {
            var dic = new RouteValueDictionary();



            foreach (var item in menuItem.QueryValues)
            {
                dic.Add(item.Key, item.Value);
            }


            <li>@Html.ActionLink(menuItem.Name, menuItem.ControllerAction, dic)</li>

            }

But when it was pushed to the test server, the URL decided to add:

%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20

in between each parameter that was being passed through with the URL.

Not totally sure which areas to show to help with a solving the problem. Could it be the xdt:Transform:Replace used within the web.config or something totally different. Any help you can provide would be appreciated.

Thanks.

UPDATE: I found what was causing all of these spaces in the link that was being generated. The XML replace was adding in returns and spaces in the XML file when it was doing the replace. I'm going to leave this question open for now, as it's not ideal that this is happening, so the question has sort of changed to how do we stop the xdt:Replace from adding in these unwanted spaces and returns?


Solution

  • After speaking to a few people and doing a LOT of searching, I have found that this is a bug within visual studio 2010 before SP1. As the machine that is building and publishing the app hasn't got SP1 installed (It is due for an upgrade though) that this was the problem.

    To make the bug a none factor, I added a TrimEnd for the characters " ", "\r", "\n" to remove any white space from the items that are being replaced.