Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using FileUploader and a view model to post
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Titre:
Using FileUploader and a view model to post
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01648596
Message ID:
01648596
Vues:
36
Hi everybody,

I am wondering if anyone implemented the File Uploader with the ASP.NET MVC and Windows API. I'm having problems :(

My last attempt is the following:

I created this class
 public class FileUploadResult
    {
        public String FileName { get; set; }
        public String Key { get; set; }
        public int PercentComplete { get; set; }
        public HttpPostedFile Content { get; set; }
        
        public string Type { get; set; }
    }
and in my JavaScript file I attempt to save file as the Content property. So far so good.

However, I am unable to post that info using my model which is the following:
 public class EditMessageViewModel
    {
        public short FormType { get; set; }
        public int MessageId { get; set; } // MessageID (Primary key)
        //public byte ReciptType { get; set; } // ReciptType. Type of recipient.  1=Guest.
        //public decimal ReciptId { get; set; } // ReciptID. ID of the recipient.  I.e. if recipient type is a guest, then guest_no.
        public string Body { get; set; } // Body
  //      public System.DateTime DateTime { get; set; } // date_time
  //      public System.Nullable<System.DateTime> Delivered { get; set; } // delivered
        public System.DateTime Expires { get; set; } // expires

        public string MsgFrom { get; set; }

        public string Subject { get; set; }

        public List<FileUploadResult> Attachments { get; set; }

        public List<GuestsList> Recipients { get; set; }
    }
However, when I try to post I'm getting the 'Bad Request' right away, so apparently I can not post such model back.

So, how exactly should I post both my model and the files I'm trying to upload?

--------------------------
The alternative way is to somehow persist the file on the server. I am guessing I may have either a global temporary table or the actual table to save the files and when I am saving my model just get the files by the key - it's another possibility which I may work on tomorrow.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform