Using Umbraco API in code behind causes PageRequestManagerServerErrorException
Hi.
This is the situation: I'm creating an Ajax comment form for my site. At first I solve it with writing a BaseExtension class, that processed post request from the page, and that worked. But then I've decided to add AST.NET Captcha module. So, I've edited my form, added a code-behind file with event handler for submit action. Handler calls function, that verifies the captcha-input field value and, if true, have to create new Document under certain node.
... using umbraco; using umbraco.webservices; using umbraco.cms.businesslogic.web; using umbraco.presentation.nodeFactory; namespace CommentForm { public partial class Itemmaster : System.Web.UI.MasterPage { ... protected void Submit_Clicked(object sender, EventArgs e) { System.Threading.Thread thread = new System.Threading.Thread(() => { CaptchaCode.ValidateCaptcha(CaptchaInput.Value); if (CaptchaCode.UserValidated) { CaptchaInput.Value = "RIGHT!"; // -- works; Node root = new Node(-1); // -- fails!; } else { CaptchaInput.Value = "WRONG!"; } }); thread.SetApartmentState(System.Threading.ApartmentState.STA); thread.Start(); } ... } }
Umbraco 4.5.2, .NET 3.5
All this works partially: the Captcha verifies without problems and I can, for example, place text "Success" or "Error" back to page. But since I need to create new Document, I try to get current node's Id. And when I add any code, that uses Umbraco API, I receive:
Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0
Using Umbraco API in code behind causes PageRequestManagerServerErrorException
Hi.
This is the situation: I'm creating an Ajax comment form for my site. At first I solve it with writing a BaseExtension class, that processed post request from the page, and that worked. But then I've decided to add AST.NET Captcha module. So, I've edited my form, added a code-behind file with event handler for submit action. Handler calls function, that verifies the captcha-input field value and, if true, have to create new Document under certain node.
Form:
Code behind fragment:
Umbraco 4.5.2, .NET 3.5
All this works partially: the Captcha verifies without problems and I can, for example, place text "Success" or "Error" back to page. But since I need to create new Document, I try to get current node's Id. And when I add any code, that uses Umbraco API, I receive:
I'm new to .NET and I hope for your help. Thanks.
is working on a reply...