Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my url, after url rewriting now appears this: %E2%80%8B

Product/SubCategories/94/Audi-50 (86)-1.1/Air filter/43420‌%E2%80%8B

It should be

Product/SubCategories/94/Audi-50 (86)-1.1/Air filter/43420‌

I know that this is somewhere a white space, I tried to resolve this, but without any success.

I use this route:

C#
routes.MapRoute(
          name: "Detail",
          url: "{controller}/{action}/{selected}/{category}/{code}‌​",
          defaults: new { controller = "Product", action = "ProductDetails" }
      );


This is the href that points to the mentioned url.
C#
<a href="@Url.Action("ProductDetails", "Product" , new { code=@c.Code.Replace(" ", string.Empty), selected=@selectedCar, category=@c.Name})" id="link">
 Details
</a>


What I have tried:

I've tried to resolve this white space problem with
C#
Trim()
I've tried with
C#
Replace("%E2%80%8B", string.Empty)


I've tried with:

C#
string encodedString = Server.HtmlEncode(code);


None of these had fixed this problem. Do you have any other ideas what can I try more, in order to fix this problem? Thanks!
Posted
Updated 28-Mar-17 23:50pm

1 solution

the url which you have given in your question is having 4 parameters
Product/SubCategories/94/Audi-50 (86)-1.1/Air filter/43420‌
94-?
audi..- selected
air filter- category
code - 43420

you have to make sure you pass three values in parameter.
however
There are few more things which you can try
try 1: add the other optional parameters entry as well

C#
routes.MapRoute(
          name: "Detail",
          url: "{controller}/{action}/{selected}/{category}/{code}‌​",
          defaults: new { controller = "Product", action = "ProductDetails", selected=UrlParameter.Optional,category = UrlParameter.Optional, code=UrlParameter.Optional }
      );


try 2: assign parameter in order
HTML
<a href="@Url.Action("ProductDetails", "Product" , new { selected=@selectedCar, category=@c.Name, code=@c.Code})" id="link">
 Details
</a>
 
Share this answer
 
Comments
Orsi 29-Mar-17 6:22am    
Hi. Thank you very much for your time. I've tried both of the solutions you have suggested, but the problem still persist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900