Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

First of all I am new in MVC. And I am working on file Upload part which is all together not passing control from Ajax Js call to controller itself. Below is the code: View from Dialog.cshtml

Upload your customized Microsoft Word Document as a confirmation letter

From Model.js

function uploadConfirm(summary, data) {
    clearErrorMessage();

    return $.ajax({
        type: "post",
        url: "/Confirmation/Upload?",
        processData: false,
        contentType: false,           
        data: data
    }).success(
        function getSucceeded(data) {
            summary.confirmationID(data);
            refreshSummary(summary);
        }).fail(onAjaxError);
}

Now this should call Upload function in my controller. The code of Upload as below From ConfirmationController.cs

    [HttpPost]
    [SharePointContextFilter]
    public ActionResult Upload(Guid id, HttpPostedFileBase doc)
    {
        string extension = Path.GetExtension(doc.FileName);
        if (extension == null || !extension.StartsWith(".doc", StringComparison.OrdinalIgnoreCase))
        {
            throw new ArgumentException("Unsupported doc type. Only .dox or .docx files are acceptable.");
        }
        return Generate(id, null, null, doc.InputStream);
    }

Now when I am putting debugger in my Model.js file it should debug me to Controller Upload function. But after moving from jquery file it just comes back in success part saying "An unexpected error occurred please contact admin" Can some one help me in understanding this.

share|improve this question
 
for the url use '@Url.Action("Action", "Controller")', try doing a console.log on the data to make sure what you are wanting sent to the controller is defined there –  Matt Bodily Jan 10 at 16:16
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.