0

I am facing this strange problem inside my enterprise wiki site collection inside sharepoint enterprise server 2013.

now when i try to create a new wiki page using the UI , and i enter some special characters such as & or * inside the Name field, i will get the following error :-

Page name cannot contain any of the following characters: " # % & * : < > ? \ / { } ~ |

as follow:-

enter image description here

but i have an event receiver where i am programmatically creating wiki pages inside the same site collection and the same library. and inside the event receiver i am able to create wiki page which contain special characters inside their wiki page name , here is the code i am using to create wiki pages:-

PublishingSite pSite = new PublishingSite(properties.Site);
SPContentType ctype = pSite.ContentTypes["Enterprise Wiki Page"];
PageLayoutCollection pageLayouts = pSite.GetPageLayouts(ctype, true);
PageLayout pageLayout = pageLayouts["EnterpriseWiki.aspx"];
PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(properties.Web);

///First page
PublishingPageCollection pPages = pWeb.GetPublishingPages();
string itemTitle = properties.ListItem.Title.Trim();
PublishingPage pPage = pPages.Add(itemTitle + ".aspx", pageLayout);

and the generated URL for the wiki page will be as follow inside the browser (where the itemTitle variable will be "L & F"):-

/Pages/L%20&%20F.aspx

here is a screen shot from my browser:-

enter image description here

so can anyone advice on this and where the problem is? i mean is it a limitation inside the UI which prevent us from adding some special characters inside the wiki pages names? or the problem is within the server side API which is not returning any error when the page name contain these special characters ? i am a bit confused on how i need to appraoch this? should i for example check the page name for these special characters before adding it inside my event receiver ?

3
  • most likely they have client side validation to prevent them but nothing in the server side that validates the string, which falls in line with what you are seeing Commented Feb 1, 2017 at 19:25
  • @EricAlexander thanks for the reply and the hint, so generally speaking is it ok to have wiki pages names containing these special characters ? or it is better to not allow these special charecters since those are not allowed from the UI?
    – John John
    Commented Feb 1, 2017 at 22:37
  • @EricAlexander now i think i find what might be causing this problem,, now the value in my case is retrived from a Term inside a term store. and seems inside the term when we add "&" it will not be saved as the regular ampersand,, it is a special character that looks like the regular ampersand !!! the actual character which is stored inside the term and i am passing in inside the wiki page name is = & and not &,, and seems the first one & is valid inside the wiki page name even from the UI...
    – John John
    Commented Feb 1, 2017 at 23:11

1 Answer 1

0

There are differences between UI and API and more than one. I would go with the lowest common denominator so if something is forbidden in UI try not to change it (as general rule) and apply same restrictions on any automation you are implementing. With SP 2016 ampersand is no longer limitation so API may be a bit ahead.

1
  • now i think i find what might be causing this problem,, now the value in my case is retrived from a Term inside a term store. and seems inside the term when we add "&" it will not be saved as the regular ampersand,, it is a special character that looks like the regular ampersand !!! the actual character which is stored inside the term and i am passing in inside the wiki page name is = & and not &,, and seems the first one & is valid inside the wiki page name even from the UI..
    – John John
    Commented Feb 1, 2017 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.