don't get my node back with linq after response.redirect
With this code I just create a new umbraco node (OrderDocType) and refresh the current page, after the response.redirect I try to get my order back with linq.
When I do so I don't get my node back until I hit F5. Does anybody know how to solve this problem?
protected void Page_Load(object sender, EventArgs e) { if (Request["product"] != null) { var orderNr = DateTime.Now.ToString("yyyyMMdd") + "-" + StringHelper.TruncString(Guid.NewGuid().ToString().Replace("-", ""), 20, false); var docOrder = DocumentType.GetByAlias("OrderDoctype"); var newOrder = Document.MakeNew(orderNr, docOrder, new User(0), 1234); newOrder.getProperty("orderNr").Value = orderNr; newOrder.Publish(admin); library.UpdateDocumentCache(newOrder.Id);
CookieHelper.AddCookie("OrderNr", orderNr);
var current = Node.GetCurrent(); Response.Redirect(current.NiceUrl); } else { if (CookieHelper.GetCookie("OrderNr") != null) { var orderNr = CookieHelper.GetCookie("OrderNr"); _ctx = new WebsDataContext(); var order = (from o in _ctx.OrderDoctypes where o.OrderNr == orderNr select o).First(); _ctx.Dispose(); } } }
The problem is that use a specific id (OrderNr) to get the order instead of the id of the node so working with the NodeFactory is a bit diffcult I think.
the umbracodatacontext reads from the umbraco.config xml file. And if you look at the following comment in umbraco.content.QueueXmlForPersistence()
/// <summary> /// Marks a flag in the HttpContext so that, upon page execution completion, the Xml cache will /// get persisted to disk. Ensure this method is only called from a thread executing a page request /// since umbraco.presentation.requestModule is the only monitor of this flag and is responsible /// for enacting the persistence at the PostRequestHandlerExecute stage of the page lifecycle. /// </summary> private void QueueXmlForPersistence() { /* Alex Norcliffe 2010 06 03 - removing all launching of ThreadPool threads, instead we just * flag on the context that the Xml should be saved and an event in the requestModule * will check for this and call PersistXmlToFile() if necessary */
So the XML is not updatede until the the end of the page request and therefore you don't get an updated umbracodatacontext until next time the page is loaded
don't get my node back with linq after response.redirect
With this code I just create a new umbraco node (OrderDocType) and refresh the current page,
after the response.redirect I try to get my order back with linq.
When I do so I don't get my node back until I hit F5.
Does anybody know how to solve this problem?
I can't remember if the publishing is async, if that's the case it may be a problem, that's the only thing I can think could be a problem.
But TBH I haven't tried doing what you're doing so I haven't had that problem arise.
Does it exist if you go via NodeFactory?
Thx for your reply.
The problem is that use a specific id (OrderNr) to get the order instead of the id of the node so working with the NodeFactory is a bit diffcult I think.
How about trying to access it through umbraco.library and an XPath statement there.
Will do it with XPath.
Find it a bit strange it seems that I'm the onlyone using Linq & the Datacontext this way but at least we have wa way around it.
Hi Slace,
I've also had this problem when I was having my level 2 course with Per Ploug. Thought that he sent you an email about this. Guess not...
It doesn't happen with the nodeFactory.
Hope this can be fixed for 4.6.
Jeroen
I've also added a workitem for it: http://umbraco.codeplex.com/workitem/29632.
Jeroen
@Jeroen, you got my vote.
I think I can explain what is going on.
the umbracodatacontext reads from the umbraco.config xml file. And if you look at the following comment in umbraco.content.QueueXmlForPersistence()
/// <summary> /// Marks a flag in the HttpContext so that, upon page execution completion, the Xml cache will /// get persisted to disk. Ensure this method is only called from a thread executing a page request /// since umbraco.presentation.requestModule is the only monitor of this flag and is responsible /// for enacting the persistence at the PostRequestHandlerExecute stage of the page lifecycle. /// </summary> private void QueueXmlForPersistence() { /* Alex Norcliffe 2010 06 03 - removing all launching of ThreadPool threads, instead we just * flag on the context that the Xml should be saved and an event in the requestModule * will check for this and call PersistXmlToFile() if necessary */So the XML is not updatede until the the end of the page request and therefore you don't get an updated umbracodatacontext until next time the page is loaded
is working on a reply...