Microsoft Content Management Server - SiteMapProvider Error on Page Creation

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > September 2007 > SiteMapProvider Error on Page Creation





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author SiteMapProvider Error on Page Creation
drazic19

2007-09-18, 7:23 am

Hi all,

I'm using custom sitemapproviders in my .net 2.0 websites which function
"semi" correct except when i try to create a new page at this point an error
is thrown:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Public Overloads Overrides Function GetParentNode(ByVal node As SiteMapNode)
As SiteMapNode
Dim ci As ChannelItem =
TryCast(CmsHttpContext.Current.Searches.GetByGuid(node.Key), ChannelItem)
Return GetSiteMapNodeFromChannelItem(ci.Parent) <-- Error
End Function

Also my breadcrumbs always show as:
Channels / ProjectName / ChannelName / PageName

Even though i provide the rootChannel as my hostheaded domain name, ideally
i only want HomeLink / ChannelName / PageName

Any help would be appreciated.

Thanks in advance,

Michael
Stefan Goßner [MSFT]

2007-09-18, 7:23 am

Hi Michael,

for the second issue you need to add some logic to your GetParentNode method
that stops when the root channel you like (HomeLink) has been delivered.

for the first issue you need to need to add this logic:

if (ci == null)
{
parent = CmsHttpContext.Current.Channel;
}
else
{
parent = ci.Parent;
}

See here for details:
http://blogs.technet.com/stefan_gos...ion-Part-1.aspx

Cheers,
Stefan

"drazic19" <michaeldraisey@nospam.nospam> wrote in message
news:9DB1BE59-4A78-4E34-852E-EF922F79CB83@microsoft.com...
> Hi all,
>
> I'm using custom sitemapproviders in my .net 2.0 websites which function
> "semi" correct except when i try to create a new page at this point an
> error
> is thrown:
>
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
>
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
> Public Overloads Overrides Function GetParentNode(ByVal node As
> SiteMapNode)
> As SiteMapNode
> Dim ci As ChannelItem =
> TryCast(CmsHttpContext.Current.Searches.GetByGuid(node.Key), ChannelItem)
> Return GetSiteMapNodeFromChannelItem(ci.Parent) <-- Error
> End Function
>
> Also my breadcrumbs always show as:
> Channels / ProjectName / ChannelName / PageName
>
> Even though i provide the rootChannel as my hostheaded domain name,
> ideally
> i only want HomeLink / ChannelName / PageName
>
> Any help would be appreciated.
>
> Thanks in advance,
>
> Michael



Wiper

2007-09-18, 1:22 pm

Hi Stefan

DL the sample...the result states:

path: /resources/Site/Resourcefolder/subfolder/logo.jpg
Page count: 0

I assume then that this ressource can be deleted as no posting uses it ?

There's a lot stated and if the above is correct I have a lot of manual
cleaning up to do - are there any SQL script out there that can clean up
automatic ?

cheers
Wiper

"drazic19" <michaeldraisey@nospam.nospam> skrev i meddelelsen
news:9DB1BE59-4A78-4E34-852E-EF922F79CB83@microsoft.com...
> Hi all,
>
> I'm using custom sitemapproviders in my .net 2.0 websites which function
> "semi" correct except when i try to create a new page at this point an
> error
> is thrown:
>
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
>
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
> Public Overloads Overrides Function GetParentNode(ByVal node As
> SiteMapNode)
> As SiteMapNode
> Dim ci As ChannelItem =
> TryCast(CmsHttpContext.Current.Searches.GetByGuid(node.Key), ChannelItem)
> Return GetSiteMapNodeFromChannelItem(ci.Parent) <-- Error
> End Function
>
> Also my breadcrumbs always show as:
> Channels / ProjectName / ChannelName / PageName
>
> Even though i provide the rootChannel as my hostheaded domain name,
> ideally
> i only want HomeLink / ChannelName / PageName
>
> Any help would be appreciated.
>
> Thanks in advance,
>
> Michael


drazic19

2007-09-19, 1:23 pm

Hi Stefan,

Thanks for the snippet. The sitemapprovider now doesn't throw an error when
a new page is created. Will work on the logic for the second issue now. Roll
on MOSS projects...

Thanks,

Michael

"Stefan Goßner [MSFT]" wrote:

> Hi Michael,
>
> for the second issue you need to add some logic to your GetParentNode method
> that stops when the root channel you like (HomeLink) has been delivered.
>
> for the first issue you need to need to add this logic:
>
> if (ci == null)
> {
> parent = CmsHttpContext.Current.Channel;
> }
> else
> {
> parent = ci.Parent;
> }
>
> See here for details:
> http://blogs.technet.com/stefan_gos...ion-Part-1.aspx
>
> Cheers,
> Stefan
>
> "drazic19" <michaeldraisey@nospam.nospam> wrote in message
> news:9DB1BE59-4A78-4E34-852E-EF922F79CB83@microsoft.com...
>
>
>

drazic19

2007-09-19, 1:23 pm

Hi again Stefan,

You state i need to "stops when the root channel you like (HomeLink) has
been delivered". How do you go about "stopping" the sitemapprovider looping
through the GetParentNode. I presume it loops through returning the parent of
the current item until null/nothing is returned?

Thanks,

Michael

"Stefan Goßner [MSFT]" wrote:

> Hi Michael,
>
> for the second issue you need to add some logic to your GetParentNode method
> that stops when the root channel you like (HomeLink) has been delivered.
>
> for the first issue you need to need to add this logic:
>
> if (ci == null)
> {
> parent = CmsHttpContext.Current.Channel;
> }
> else
> {
> parent = ci.Parent;
> }
>
> See here for details:
> http://blogs.technet.com/stefan_gos...ion-Part-1.aspx
>
> Cheers,
> Stefan
>
> "drazic19" <michaeldraisey@nospam.nospam> wrote in message
> news:9DB1BE59-4A78-4E34-852E-EF922F79CB83@microsoft.com...
>
>
>

Stefan Goßner [MSFT]

2007-09-19, 1:23 pm

Hi Michael,

your provider can return null whenever it is designed to do so.
Just return null rather than the "channels" object.

Cheers,
Stefan


"drazic19" <michaeldraisey@nospam.nospam> wrote in message
news:3239EF8A-C79F-4FC8-83EF-3213444F7DD7@microsoft.com...[vbcol=seagreen]
> Hi again Stefan,
>
> You state i need to "stops when the root channel you like (HomeLink) has
> been delivered". How do you go about "stopping" the sitemapprovider
> looping
> through the GetParentNode. I presume it loops through returning the parent
> of
> the current item until null/nothing is returned?
>
> Thanks,
>
> Michael
>
> "Stefan Goßner [MSFT]" wrote:
>


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com