Reputation: 11
I have such Url: /%20Account/%20LogOn?ReturnUrl=%2f+Admin%2f+Index
I have two questions:
1)Why I have %20
before Account
and LogOn
? Is it something like spaces?
2)How to remove %20
before Account
and LogOn
?
Maybe something wrong with Routes?
It's my class RegisterRoutes:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
null,
"",
new { controller = "Product", action = "List",category = (string)null,page=1 }) ;
routes.MapRoute(null,
"Page{page}",
new { controller = "Product", action = "List",category = (string)null });
routes.MapRoute(
null,
"{category}",
new { controller = "Product", action = "List", page = 1 });
routes.MapRoute(
null,
"{category}/Page{page}",
new { controller = "Product", action = "List"});
routes.MapRoute(null, " {controller}/ {action}");
}
Upvotes: 1
Views: 2847
Reputation: 31
I had a similar problem in my application, where %20 appears at the end of the url. I had to use .Trim() in order to remove the space before I pass in the required id.
@Html.ActionLink("Details", "Details", new { id = item.ID_NO.Trim()})
and that solved my problem.
Upvotes: 0
Reputation: 140803
1)Why I have %20 before Account and LogOn? Is it something like spaces?
This is because you have space inside the URL string. Those are converted into encoded string which for the same is %20
2)How to remove %20 before Account and LogOn?
You need to create a link without a space before Account and LogOn. If you are using Html Helper to create the link, you may have not noticed a space before the string of the action.
Upvotes: 1
Reputation: 4268
Because your url contains white space between words,
For example when you enter this ('somesite.com/some thing') address in your browser, your browser encode that address to 'somesite.com/some%20thing'
then to decode your URL
in code behind, you can use Server.UrlDecode("someURL")
Upvotes: 1
Reputation: 198
1) That is the encoded URL
.
2) Not sure in what context you are using it but you can decode it using Server.UrlDecode("string")
Upvotes: 0