Search code examples
asp.nettypesmime

How should I detect the MIME type of an uploaded file in ASP.NET?


How do people usually detect the MIME type of an uploaded file using ASP.NET?


Solution

  • in the aspx page:

    <asp:FileUpload ID="FileUpload1" runat="server" />
    

    in the codebehind (c#):

    string contentType = FileUpload1.PostedFile.ContentType