Jul 16, 2012, 12:34 PM
[CLOSED] [Razor] File upload field - bad response?
Hi, I'm trying to get upload file on server with file upload field with this code:
In my object o I got file object. That is ok. Problem is because I have some error message on client after controller executes code.
This is what I got as answer:
Status Text: BADRESPONSE: Unexpected token <
Thanks!
@(Html.X().FormPanel().ID("PanelP1")
.Items(items => {
items.Add(Html.X().FileUploadField().ID("fuf1").Text("Add file"));
})
.Buttons(buttons =>
{
buttons.Add(Html.X().Button().ID("ButtonSave1").Text("Save").Icon(Icon.DatabaseSave)
.DirectEvents(directEvents =>
{
directEvents.Click.IsUpload = true;
directEvents.Click.Confirmation.ConfirmRequest = true;
directEvents.Click.Confirmation.Title = "Save";
directEvents.Click.Confirmation.Message = "Confirm?";
directEvents.Click.Url = "/Test/SaveR";
directEvents.Click.EventMask.ShowMask = true;
directEvents.Click.EventMask.Msg = "Loading...";
})
);
})
)
And controller code is: public ActionResult SaveR()
{
try
{
object o = Request.Files[0];
return (new AjaxResult { Script = X.Msg.Alert("Title", "Response test").ToScript() });
}
catch (Exception exc)
{
return (new AjaxResult { Script = X.Msg.Alert("Title", "Error: " + exc.Message).ToScript() });
}
}
In my object o I got file object. That is ok. Problem is because I have some error message on client after controller executes code.
This is what I got as answer:
Status Text: BADRESPONSE: Unexpected token <
{script:"Ext.Msg.show({title:\"Title\",buttons:Ext.Msg.OK,msg:\"Response test\"});"}
(In IE I got option to save file with this content.) Why server sends me this text as answer and how to fix this?Thanks!
Last edited by Daniil; Jul 16, 2012 at 1:11 PM.
Reason: Please use [CODE] tags for any code, [CLOSED]