November Happy Hour will be moved to Thursday December 5th.

Problem with search for pages

Vote:
 
Hi

I have a question here and wonder i you can help me?. The thing is im pretty new at working with episerver developing, and I have a problem.
I'm trying to create and publish a page from a form in a winform appication to EPiServer. When this is done I also want to search the site for those pages but this is where the problem appear, When I publish the pages from the application and search for them on my search page on the site i cant find them, but when i login and go to  "edit mode" and "Save and publish" the pages i can find them when I search for them again.

So I wonder if their is anyway to be able to find the pages when im publish them from the application and not with "Save and publish" for the pages in editmode?.

#26527
Dec 10, 2008 10:17
Vote:
 

Do you have SaveAction set to Publish in your save page code?

ex:

DataFactory.Instance.Save(newPage, SaveAction.Publish);

- Kjetil Simensen

#26531
Dec 10, 2008 11:24
Vote:
 

I am having the exact same problem.

I've written code to add a page to Episerver:

DataFactory.Instance.Save(newClonedPage, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);

When my scheduled job starts to add more pages it checks to see if this page has already been published - but it doesnt find this page.

If I am logged onto the Episerver interface, then the page can be found, but if I am not logged in then I cant find the page.

I hope someone can provide a solution for this problem!

A related question would be: What user is used when the Job scheduler executes jobs?

#31198
Jul 08, 2009 10:53
Vote:
 

Hi

When do you do the search, directly after the page is created? If so it could be a good idea to set the start publish slightly in the past:

newClonedPage.StartPublish.AddMinutes(-1);

The reason for that is that EPiServer might not see the page as published if the search comes direclty after the page has been created, and thus filtering the page if the user is anonymous.

It could also be an access rights problem, if the currently logged lacks read access to the page it will not be returned from the search.

"A related question would be: What user is used when the Job scheduler executes jobs?"

When the job is run by the scheduler, it will be run as an anonymous user. If you select "start manualy" from the UI it will be run with as the user that started the job.

Regards

Per Gunsarfs
EPiServer CMS development team

#31199
Jul 08, 2009 11:29
Vote:
 
Per, thank you for the speedy response...

The page is almost a day old when I search for it through the job that I've scheduled...  I think the problem is that with the scheduled job the anonymous user is not allowed to find that page - even through code - so the episerver search in my Job does not function properly?

How can I find these pages through code as an anonymous user? Currently I am having the problem of duplicate pages since I cannot verify through code that a page already exists.

I use:

EPiServer.DataAbstraction.SearchPages fbn = new EPiServer.DataAbstraction.SearchPages();
PageReference infrPage = fbn.FindByName(infshort.InfringeNoticeN);

but I've also tried to find it by Criteria... same problem!

Thank you

Deon

#31201
Jul 08, 2009 11:40
Vote:
 

Hi

Two ways to find pages in a scheduled job that anonymous users lacks access to.

1. To impersonate a user for the job. I think I saw a blog post somewhere describing how.

2. Use the method EPiServer.DataFactory.FindAllPagesWithCriteria. It's a rather new method, think it was added to EPiServer CMS R2 perhaps SP1. It was made to support just this issue. It will return all hits, leaving the filtering up to you.

Noticed you were using the FindByName method. Since FindAllPagesWithCriteria is more generic you'll have to create a criteria to match PageName yourself.

Edit: Found the blog post I mentioned, http://antecknat.se/blog/2009/03/04/scheduled-tasks-tips/.

Regards

Per Gunsarfs

#31204
Edited, Jul 08, 2009 13:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.