LoadXML Error Writing to Database

I am getting the error shown in the attached graphic. I am using SQL Server 2008 as the database. When I save a new entry, be it a single event or a recurring event, the error screen is displayed. However, if I close the web site and re-open it, the new event is displayed without any problems, so the new data has been saved to the database correctly. What is creating the XML after a save? Is it the Data.aspx view or something else? The Controller code I am using is taken from your scheduler_aspnet_mvc.zip example. I haven’t made any changes to it. I have it working without problems in another project but that is using a .mdf file in App_Data.

I am using ASP.NET MVC3 and EF Code First.


Please check the code itself which is returned from the server side after save operation (it seems incorrect XML is returned :slight_smile:).

Best regards,

Hi Ilya

This is the only code that is executing when I save the event.

public ActionResult Save( Event changedEvent, FormCollection actionValues )
	String action_type = actionValues["!nativeeditor_status"];
	Int64 source_id = Int64.Parse( actionValues["id"] );
	Int64 target_id = source_id;

	MyWebSiteDb eventData = new MyWebSiteDb();
		switch (action_type)
			case "inserted":
				eventData.Events.Add( changedEvent );
			case "deleted":
				changedEvent = eventData.Events.SingleOrDefault( ev => ev.EventID == source_id );
				eventData.Events.Remove( changedEvent );
			default: // "updated"
				changedEvent = eventData.Events.SingleOrDefault( ev => ev.EventID == source_id );
				UpdateModel( changedEvent );
		target_id = changedEvent.EventID;
		action_type = "error";

	return View( new CalendarActionResponseModel( action_type, source_id, target_id ) );

public class CalendarActionResponseModel
	public String Status;
	public Int64 Source_id;
	public Int64 Target_id;

	public CalendarActionResponseModel( String status, Int64 source_id, Int64 target_id )
		Status = status;
		Source_id = source_id;
		Target_id = target_id;

This code is taken directly from your MVC example without any change. I don’t understand where the XML is being created. I don’t understand why it is complaining when the data is being written to the table correctly.

I have found the problem causing the error message.

Even though the event scheduler is displayed on a content page, the Data.aspx and Save.aspx views must Not include MasterPageFile="~/Views/Shared/Site.Master" on the <%@ Page … %> definition line.

Hi Ilya

I have started to get the same error message again, and it is not because of an incorrect <%@ Page … %> line. My ASP.NET MVC ActionResult Save etc is exactly as shown in my previous comment and my Save.aspx routine contains the following:

[code]<%@ Page Title="" Language=“C#” Inherits=“System.Web.Mvc.ViewPage<RLSBC_WebSite.Controllers.CalendarActionResponseModel>” ContentType=“text/xml” %>

[/code] Again, this is exactly as in your ASP.NET MVC example. I have shown you the server-side code that is being executed; it is the code you provided. I don't understand where the XML is being created. I don't understand why it is complaining when the data is being written to the table correctly. Can you please provide me some more clues.

can you provide server response with that incorrect xml?

Hi Aliaksandr

I don’t get any response apart from the error message attached to my original post. I don’t even know what XML is being executed because I can’t display it, so I don’t know whether it is correct or not.

After the call to the Save Controller code to update the database, I don’t understand what the Save view is trying to do with the three values that have been passed in. Do I need additional values in the Save view because I have extended the database to store recurring and coloured events? (I have added them to the Data.aspx view.) I have four extra fields on the data table.

After reading another post about this problem, I was pointed to the onAfterUpdate event. This has the same 3 parameters returned by the CalendarActionResponseModel class. But, in addition, it has an xml_node parameter. It would appear this is being generated incorrectly by some unknown code. Is it because of the extra four fields on the database, as suggested above?

Could someone please reply to my previous post, either to say that there will be no reply or to try and explain to me how the XML file is generated after the return from Save.aspx view so that I might try and debug what is going wrong. This is the last thing that needs correcting before I can upload my website.


please show what server returns after that save request,
in firefox with firebug you can see all requests in “net” tab(can download firebug from fiddler2.com/fiddler2/),
post response text here, it should give some clue

The nearest I can get is the following piece of code from the HTML used to re-display the page. I have only included a selection of the events, including the last one entered.


18:00 New event
13:00 Changed Test Event
13:00 My Changed Test Event
09:00 Get HTML Event
09:00 Another Event
09:00 New event
[/code] The fourth event is the last one entered. Is event_id="1310114791934" correct or should it be event_id="35", which is the event_id in the database?

ids on the client side should be the same as in db

when you add event on the client it got temporary id(event_id=“1310114791934”)
and scheduler sends save request; after record has been inserted in database, server sends response with it’s actual id(event_id=“35”) like that

<data><action type="inserted" sid="1310114791934" tid="35"></action></data>

client will replace temporary id with recieved one, but since you’ve got incorrect xml in response it doesn’t do it

I have found the reason why changed events were not being re-displayed correctly. It was not because the XML file was incorrect but because I had the wrong reference to the XML file in the <%@ Page declaration in the Save.aspx file. A thousand apologies for wasting your time. I really must try harder.

Everything is now working fine so I can now install the new version of the website.