Problem
I had a lot of issues getting AJAX to work correctly in BlogEngine.NET 1.6. After updating 3 times, the request URL gets screwed up and a PageRequestManagerServerErrorException was raised with a 404 status code.
Solution
I am listing steps I took to get AJAX installed. Solution to the AJAX issue is at the end of the post.
Steps to Installing AJAX
First I only wanted AJAX added for ASP.NET Web User Control (ASCX) files I develop. So I didn’t add it to the entire website.
Created a simple ASCX to generate random passwords with the link of: http://www.itbrigadeinc.com/post/2012/01/07/Random-Password-Generator.aspx.
Tested this ASCX on my local development server (not in BlogEngine yet).
Discovered I had to use the AJAX Control Toolkit instead of the AJAX Extensions that included in Visual Studio. Can download the AJAX Control Toolkit here.
Used the .NET 3.5 version of the Toolkit since that is what I am building BlogEngine with.
Retested on local server and worked fine.
Added ASCX to BlogEngine.NET – this is where I started getting problems
Received the following error on 3rd click of the button:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404.
The HTTP request was:
http://localhost:52457/BlogEngine.NET/post/2012/01/07/post.aspx?id=0fb34787-b32d-4c96-a653-aea78ca90ea4
when it should have been:
http://localhost:52457/BlogEngine.NET/post.aspx?id=0fb34787-b32d-4c96-a653-aea78ca90ea4
So it was not requesting the correct page and thereby giving the 404 error.
Solution
After much research on the internet, I found that someone had a simple solution.
Just add this script block to the end of your ASCX control and it corrects the HTTP request back to:
http://www.itbrigadeinc.com/post/2012/01/07/Random-Password-Generator.aspx
Solution
- <script type="text/javascript">
- Sys.Application.add_load(function () {
- var form = Sys.WebForms.PageRequestManager.getInstance()._form;
- form._initialAction = form.action = window.location.href;
- });
- </script>

John Dorsey
IT Brigade Inc.
www.itbrigadeinc.com
ASP.NET, BlogEngine.NET
AJAX, BlogEngine.NET