View Full Version : [CLOSED] Issue returning error(s) from an Api Controller

May 22, 2014, 1:34 PM
I have a FormPanel that contains a FileUploadField and which invokes an Api Controller action using a DirectEvent in this way :-

.DirectEvents(de =>
de.Click.Url = @Url.RouteUrl("AlternateApi", new { httproute = "", controller = "AdministrationApi", action = "CertifyAward" });
de.Click.EventMask.ShowMask = true;
de.Click.IsUpload = true;
de.Click.Success = "onCertifyAwardSuccess(result);";
de.Click.Failure = "onCertifyAwardFailure(result);";

If the Api Controller action returns Request.CreateResponse(HttpStatusCode.OK), all is well. The issue is when I have to return an error. The browser hangs for a long time (30 secs or so) and I get an error in the returned AXD of "Access Denied" which seems to be associated with "onUploadComplete".

To test error return methods I simply return an error response. I tried both throwing a HttpResponseException and also returning a CreateErrorResponse like this :-

public async Task<HttpResponseMessage> CertifyAward()

throw new HttpResponseException(Request.CreateErrorResponse(
"OMG, I like totally FAILED."));

// Verify that this is an HTML Form file upload request
if (!Request.Content.IsMimeMultipartContent("form-data"))
return Request.CreateErrorResponse(HttpStatusCode.Unsuppo rtedMediaType, "Unsupported Media Type.");

Both the above result in the "Access Denied" AXD error. To try and track down error further I used an override of onUploadComplete (only partially listed) :-

<script type="text/javascript">
onUploadComplete: function(frame, options) {
var me = this, // bogus response object
response = {
responseText: '',
responseXML: null
}, doc, contentNode;
try {
doc = frame.contentWindow.document || frame.contentDocument || window.frames[frame.id].document;

The "Access Denied" seems to pertain to frame.contentWindow

Any clues?

May 22, 2014, 5:35 PM

We are not sure it is going to work with such kind of responses. Though, needs to investigate in details. It is appreciated if you can provide us with a full and simplified sample how to reproduce the problem.