Q: I am trying to integrate n2 cms with an existing asp.net 3.5 website that uses silverlight controls, and after doing so began to get this error:
Event handlers can only be bound to HttpApplication events during IHttpModule initialization.
Also, when attempting to login to edit the site, I was getting an erorr advising that n2.security could not be found.
Hoping you can point me in the right direction!
A:
Thanx! Problem solved. Well, it works now anyway :o). According to http://help.godaddy.com/article/4162#six there have been som change regarding HttpModules and HttpHandlers in IIS7 as you stated. Anyway, I ran N2 application pool in a classic mode instead of integrated and now it works.
Cheers!
source : http://n2cms.codeplex.com/Thread/View.aspx?ThreadId=38311
Thursday, October 21, 2010
Wednesday, October 20, 2010
application_start event debug
It can be difficult to debug the application_start event due to the fact that it fires only once during the lifetime of the application. Usually, to debug this, you will need to shutdown your application so that the application_start event will fire the next time a request occurs. The easiest way to do this is to recycle IIS.
Once IIS has started back up, you can set a breakpoint in the IDE. Odds are, the IDE will not let you attach to the worker process as there is no managed code running in it or there will be no worker process running.
To get around this, you can make a request to a different application (on the same machine) to put managed code in the worker processed/start the worker process You can then attach to it with your breakpoint set and issue a request.
An easier method will probably be to add a call to System.Diagnostics.Debugger.Break() in the application_start event. This will force the IDE to attach to the process and allow you to step through. You will probably want to remove this before you check in to source control if you have other people working on it as they probably do not need to debug every application start up. The good news is that as long as your are deploying release binaries to production, a call to Debugger.Break will not cause execution to halt.
Once IIS has started back up, you can set a breakpoint in the IDE. Odds are, the IDE will not let you attach to the worker process as there is no managed code running in it or there will be no worker process running.
To get around this, you can make a request to a different application (on the same machine) to put managed code in the worker processed/start the worker process You can then attach to it with your breakpoint set and issue a request.
An easier method will probably be to add a call to System.Diagnostics.Debugger.Break() in the application_start event. This will force the IDE to attach to the process and allow you to step through. You will probably want to remove this before you check in to source control if you have other people working on it as they probably do not need to debug every application start up. The good news is that as long as your are deploying release binaries to production, a call to Debugger.Break will not cause execution to halt.
Wednesday, October 13, 2010
Create and Add nodes in .Net C# with XmlDocument
The tribal knowledge in dealing with XmlDocument in C# is that it takes the reference to a tree and its branches too literally. When pruning or adding to the tree, one must always take from the branch (node) from which it comes to do any operation. Here are a few examples to work with the XmlDocument
Add Node With Attributes
string xml = @"
";'
XmlDocument originalXml = new XmlDocument();originalXml.LoadXml(xml);XmlNode menu = originalXml.SelectSingleNode("menu");XmlNode newSub = originalXml.CreateNode(XmlNodeType.Element, "sub", null);XmlAttribute xa = originalXml.CreateAttribute("Name");xa.Value = "D";XmlAttribute xb = originalXml.CreateAttribute("value");xb.Value = "p4.aspx";newSub.Attributes.Append(xa);newSub.Attributes.Append(xb);menu.AppendChild(newSub);Console.WriteLine(originalXml.OuterXml.ToString()); |
The above code we had a static set of Xml, and added a node with two attributes. Here is the output (pretty printed after the fact and not by the code)
xml version="1.0" encoding="utf-8"?><menu>
<sub name="A" value="p1.aspx" />
<sub name="B" value="p2.aspx" />
<sub name="C" value="p3.aspx" />
<sub Name="D" value="p4.aspx" />
menu>
Remove Node
Using the above snippet to remove the “B” node we will search for it then remove it
XmlNode bNode = originalXml.SelectSingleNode("descendant::sub[@name='B']");if (bNode != null)
menu.RemoveChild(bNode);
Console.WriteLine(originalXml.OuterXml.ToString());
Which produces this Output
xml version="1.0" encoding="utf-8"?><menu>
<sub name="A" value="p1.aspx" />
<sub name="C" value="p3.aspx" />
<sub Name="D" value="p4.aspx" />
menu>
Replace Xml Snippet
In this example we will simulate a user making a changes to an xml node say within an editor. All we know is that it has been changed, but we don’t know what. It could be either additions or subtractions of attributes and nodes; regardless it needs to replace an original item.
string xmlInitial =@" ";string xmlUser =@" ";XmlDocument originalXml = new XmlDocument();string targetNode = "descendant::*[name(.) ='OpenBalances']";originalXml.LoadXml( xmlInitial );// Simulate the selection of the subnode// for the user to edit in the first nodes// Rules.XmlNode editNode = originalXml.SelectSingleNode(targetNode);// Get a fragment and slide the changed data into it.XmlDocumentFragment fragment = originalXml.CreateDocumentFragment();fragment.InnerXml = xmlUser;// Replace the contents of the editNode with the user fragment.editNode.ParentNode.ReplaceChild(fragment, editNode);Console.WriteLine(originalXml.OuterXml); |
Here is the resulting output
|
Subscribe to:
Posts (Atom)