search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Error - The Request must start with JSON string

Asked by Anonymous
5 years ago.

I am working on a sample application written in ASP.NET MVC 3 with Razor view engine. I am using the DayPilot Lite(open source). When i navigate to the url whose controller contains the Daypilot control it throws the error in the controller "The request must start with JSON string". I saw the actual http request that is sent through the fiddler and i didn't saw any JSON string in the request.

Can someone help in identifying the problem and resolving it ?

Answer posted by Dan Letecky [DayPilot]
5 years ago.

You will see this error if you try to open the backend URL in a browser.

In order to show the Calendar you need two URLs (corresponding to two controller actions):

1. The first one will show a view with the Calendar control on it:

Controller:
    [HandleError]
    public class CalendarController : Controller
    {
        public ActionResult Light()
        {
            return View();
        }
     ...
   }
View:
...
@Html.DayPilotCalendar("dpc", new DayPilotCalendarConfig
{
    BackendUrl = Url.Content("~/Calendar/Backend"),
})
...
Example: http://mvc.daypilot.org/demo/Lite/Calendar/Light 2. The second one handles the AJAX requests generated by the view (#1). It has no view associated with it and it's not possible to open in directly in the browser. You need to use this url as BackendUrl in the view (#1).
  ...
  public ActionResult Backend()
  {
    return new Dpc().CallBack(this);
  }
  ...

Example:
http://mvc.daypilot.org/demo/Lite/Calendar/Backend

See also this article for a step-by-step description of the event calendar setup:
http://kb.daypilot.org/67316/how-to-show-an-event-calendar-in-asp-net-mvc-3-razor/

This question is more than 6 months old and has been closed. Please create a new question if you have anything to add.