Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Plus Signs in url do not work View modes: 
User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/3/2012 1:59:10 PM
   
Plus Signs in url do not work
Is there any specific reason why plus signs in urls do not work? I am trying to create SEO friendly URLs by url encoding names that I will use in a wildcard url.

For example:

/photos/{personname}/{eventtitle}/{photoid}

When I use Server.UrlEncode("/photos/Firstname Lastname/The Title of the Event/123") I get "/photos/Firstname+Lastname/The+Title+of+the+Event/123", which is what I want to use, however this results in a 404 error or resource cannot be found.

Even if I add the plus sign as an allowed character for the site and create a document using plus signs it does not work. Why not?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/4/2012 2:07:26 AM
   
RE:Plus Signs in url do not work
Hi,

Please see the URL configuration documentation to see what are the settings for the format of the URL and the forbidden characters replacement (and basically which characters are not allowed in the URL).

Best regards,
Juraj Ondrus

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/6/2012 10:07:49 AM
   
RE:Plus Signs in url do not work
Thank you Juraj for your help.

However, what I really want to know is why the plus sign is included among the invalid characters by default. It is what Server.UrlEncode() replaces spaces with.

I can understand wanting to exclude those characters from document aliases, but when I am using URL wildcards or MVC type routing I would like to be able to use the plus sign instead of underscores so that I can do a simple Server.UrlDecode() to get the exact value that I need to match in my custom table.

Do you understand what I mean?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/9/2012 7:20:00 AM
   
RE:Plus Signs in url do not work
Hi,

Yes, I understand. I do not know why it was added to the forbidden characters, however you can use this key in the web.config file "CMSForbiddenURLValues" and in its value specify only those characters you want to replace. So, in your case you will exclude the plus sign.

Best regards,
Juraj Ondrus

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 1/9/2012 12:24:54 PM
   
RE:Plus Signs in url do not work
Even when I add this app setting in my web.config it doesn't work.

<add key="CMSForbiddenURLValues" value="\\/:*?\"<>|&%.'#[] =" />

Note: I found the default value for this app setting on this page http://devnet.kentico.com/FAQs/General.aspx#FAQ272

I had to change it by escaping invalid XML attribute characters so as not to cause a server error.

When I am using a route url alias, everything works fine when I use a space in the URL, but it gives me a 404 error when I use a + plus sign every time. In fact, it worked with spaces in the URL even when space characters were included in teh CMSForbiddenURLValues. I really think this issue is deeper than what you think.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/10/2012 3:35:35 AM
   
RE:Plus Signs in url do not work
Hi,

what is the exact error message you are getting? Isn't it possible that you are getting this?

Could you please describe me your exact settings and step by step description how to reproduce your issue? I was able to make the plus sign work in the URL easily.

And the FAQ - yes, there is a typo in the value which causes the XML markup not to be valid - we are sorry for this but this is not a big deal I think :-)

Best regards,
Juraj Ondrus