I have this piece of test code that loops from the current page's ancestors and creates list output..you can probably guess what for. When I run this code and it gets to the home page, NiceURL puts in a hash (pound symbol) (#) instead of the single forward slash.
If I breakpoint on the last line of code here, the value of n.NiceURL will initially be '#' and if I wait a few seconds it will change to '/' and that's what gets assigned. Even if I break higher up but then let the code continue, it doesn't get those few seconds to change from hash to slash and assigns a hash.
while (n.Parent != null) { n = (Node) n.Parent; crumbs.Add(string.Format("<li><a href=\"{0}\">{1}</a></li>", n.Url, n.Name)); }
I get around it by using n.Url instead but has anyone else seen this sort of behaviour on NiceUrl and what causes it?
Do you see the "#" in the properties tab on your rootnode in the umbraco backend? Then it might help to save and publish the node or do a "republish entire site" on the "content" treeitem.
The backend for this rootnode doesn't have a '#' anywhere and the 'Link to document' is '/'.
It's very strange how it initially responds with the hash but given time will revert to the slash. I can of course republish but for this particular problem I am working around it by using .Url instead which always seems to have the correct value.
I ran into this issue today and had to revert to using Url instead of NiceUrl. The weird thing is NiceUrl works fine in other pages for the same node. I'm using 4.11.1.
I have had this issue too in V6 using NIceUrl, but just went back to the development site and cannot reproduce it. At the time I saw it I was developing the the mobile code and had a half written piece of code for a pop-up (# placeholder) and put it down to that, so pretty much ignored it.
All I can really add is that it is not there now, having gone backward, forward, up, down, in and out of mobile, but still could not reproduce it.
The # occurs at the end of the url on another page. So by commenting out code and refreshing, eliminated it, then refreshed the page again and it returned.
Continued to refresh the page and it appreared and disappeared randomly, the number of refreshes to re-appear was written down as follows;
8, 2, 4, 14, 5, 1, 1, 5, 6. I hope this is sufficient to say that it is a "random" event - but can anyone think of a suggestion as to why it may be happening, it does not seem to be affected by any code or call, just appears and disappears?
I think I have solved this, at the same time as solving another issue. My knowlwdge of the internal workings of Umbraco are limited, so I will just state what I have found in the hope that someone can explain.
var pages = CurrentPage.AncestorOrSelf("top").Children.Where("DocumentTypeAlias == \"Whatever\"").OrderBy("CreateDate desc");
worked in previous versions, but in V6 running MVC, it appears that anything afer the Children is ignored, but what it does do is randomly add a # to the url. As if the additional code is flagging an error, by adding the #, or being directed somewhere?
How do I know this?
var pages = CurrentPageAncestorOrSelf("top").Children.
@foreach ( var item in pages.Where("DocumentTypeAlias == \"Whatever\"").OrderBy("CreateDate desc"))
{ @item.Url() }
returns exactly as it should, in the right order and there is no longer # in the url.
This has taken a lot of "trying" with the dynamic CurrentPage to find this, have left out the other cases, so I hope that by posting it can help others.
As I said, I cannot explain it and will not even try - but if someone who can could post a reply - I'm sure it would be appreciated by many in the future.
Quick update on this, the # is nothing to do with Umbraco - it is from the Mvc side. According to the forums, it occurs when you have jQuery mobile installed or alternatively you are using any ajax calls. So, why some of us may have thought it was to do with NiceUrl, Url, in fact it is the ahref wrapped around it.
By adding data-ajax="false" to the reference, it should remove it.
NiceUrl on the homepage
Greetings,
I have this piece of test code that loops from the current page's ancestors and creates list output..you can probably guess what for. When I run this code and it gets to the home page, NiceURL puts in a hash (pound symbol) (#) instead of the single forward slash.
If I breakpoint on the last line of code here, the value of n.NiceURL will initially be '#' and if I wait a few seconds it will change to '/' and that's what gets assigned. Even if I break higher up but then let the code continue, it doesn't get those few seconds to change from hash to slash and assigns a hash.
I get around it by using n.Url instead but has anyone else seen this sort of behaviour on NiceUrl and what causes it?
Thanks
Hi Deci,
What version of umbraco are you running?
Do you see the "#" in the properties tab on your rootnode in the umbraco backend? Then it might help to save and publish the node or do a "republish entire site" on the "content" treeitem.
Rgds,
David
Hi David,
I am running 4.7.0
The backend for this rootnode doesn't have a '#' anywhere and the 'Link to document' is '/'.
It's very strange how it initially responds with the hash but given time will revert to the slash. I can of course republish but for this particular problem I am working around it by using .Url instead which always seems to have the correct value.
thanks for the reply,
Deci
I ran into this issue today and had to revert to using Url instead of NiceUrl. The weird thing is NiceUrl works fine in other pages for the same node. I'm using 4.11.1.
Any resolution to this or is it a bug?
Hi Guys
I have had this issue too in V6 using NIceUrl, but just went back to the development site and cannot reproduce it. At the time I saw it I was developing the the mobile code and had a half written piece of code for a pop-up (# placeholder) and put it down to that, so pretty much ignored it.
All I can really add is that it is not there now, having gone backward, forward, up, down, in and out of mobile, but still could not reproduce it.
Regards
G
Quick update on this - came across a page where it occurs;
The page conatins javascript, jquerymobile, and assorted stuff - but eliminating eveything piece by piece I found the cause.
@foreach ( dynamic d in CurrentPage.gallery)
It seems that this is one reason why NiceUrl is obsolete und future versions. Just wanted to share my thoughts about it.
This blog might have some nice tips for the home url: http://cultiv.nl/blog/2010/12/19/tip-of-the-week-the-ultimate-site-structure-setup/
Jeroen
Further update
The # occurs at the end of the url on another page. So by commenting out code and refreshing, eliminated it, then refreshed the page again and it returned.
Continued to refresh the page and it appreared and disappeared randomly, the number of refreshes to re-appear was written down as follows;
8, 2, 4, 14, 5, 1, 1, 5, 6. I hope this is sufficient to say that it is a "random" event - but can anyone think of a suggestion as to why it may be happening, it does not seem to be affected by any code or call, just appears and disappears?
G
Hi Guys
I think I have solved this, at the same time as solving another issue. My knowlwdge of the internal workings of Umbraco are limited, so I will just state what I have found in the hope that someone can explain.
var pages = CurrentPage.AncestorOrSelf("top").Children.Where("DocumentTypeAlias == \"Whatever\"").OrderBy("CreateDate desc");
Hi
Quick update on this, the # is nothing to do with Umbraco - it is from the Mvc side. According to the forums, it occurs when you have jQuery mobile installed or alternatively you are using any ajax calls. So, why some of us may have thought it was to do with NiceUrl, Url, in fact it is the ahref wrapped around it.
By adding data-ajax="false" to the reference, it should remove it.
But then again, we have all been wrong before.
regards G
is working on a reply...