This is a migrated thread and some comments may be shown as answers.

Error 500 unhandled

2 Answers 294 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 26 Aug 2014, 03:30 PM
Dear support team,

I have a grid which registeres an error event. When the model validation fails, the event is correctly triggered and I get a messagebox.

Next i tried to insert a dummy javascript (<script>alert('aaa')</script>) into the textbox.
MVC reacts on it with an error 500 ('a potential malicious request was detected')
However the onError event function is not triggered now.

@(Html.Kendo().Grid<MyViewModel>()
      .Name("kendoGrid")
      .DataSource(dataSource => dataSource
          .Ajax()
          .Model(model => {              model.Id(i => i.Id);          })
          .Create(create => create.Action("_Create", "Controller"))
          .Read(read => read.Action("_Index", "Controller"))
          .Update(update => update.Action("_Update", "Controller"))
          .Destroy(destroy => destroy.Action("_Delete", "Controller"))
          .Events(events => events.Error("onError")) // <----------- Register Error Event
      )
      .ToolBar(toolbar => toolbar.Create().Text("New"))
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Columns(column => {
          column.Bound(i => i.Name);
          column.Command(cmd => {
              cmd.Destroy();
              cmd.Edit();
          });
      })
      )
 
<script type="text/javascript">
    function onError(e) {
                          alert("test");
        if (e.errors) {
            var message = "The folowing errors occured:\n";
            $.each(e.errors, function(key, value) {
                if (value.errors) {
                    message += value.errors.join("\n");
                }
            });
            bootbox.alert(message);
        } else {
            bootbox.alert("An unknown error occured");
        }
    }
</script>


Any ideas what I've done wrong here?

btw my version is 2014.Q2

A second issue is, that I don't get a bootbox window. Instead I get a standard message box. Perhaps you have a clue on that too.

thank you,
Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 28 Aug 2014, 11:55 AM
Hello Chris,

Could you provide a runnable sample that replicates the problem? The dataSource error event should be triggered for both custom errors and an error response. 

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Christian
Top achievements
Rank 1
answered on 01 Sep 2014, 09:22 AM
Hello Daniel,

Thank you for your response. While preparing the sample for you, it came out I had a duplicate javascript funtion with the same function name still enabled. Sorry, my fault. Problem solved.
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Christian
Top achievements
Rank 1
Share this question
or