Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:23:03+00:00 2026-05-28T00:23:03+00:00

I have a simple web form that sends and email out via .NET C#.

  • 0

I have a simple web form that sends and email out via .NET C#. Additionally there is an ASP UPLOAD ctrl from which I create a memory stream and attach the stream to the Mail Message…ie no need to save file to file system.

ISSUE: When MAC users dont inlcude extensions on their uploaded files (I am testing for PostedFile.ContentType to determine the file and/or appropriate extension, allowable files RTF, TXT, PDF, DOC, DOCX) it seems like the ContentType comes back as “application/octet”…this makes some sense to me w/o an extension as required by PCs but; still unclear on weather reading the ContentType or extension is a better way to determine what type of file it is before I attach. [Extensionless MAC file will obviously fail any extension test]

Basically, I read the file from the upload ctrl, determine what its ContentType is, strip just the PostedFile.Filename and then reassemble as I create the attachment using the ContentType string in a switch statement to determine and add the correct extension to the attached file (filename + ext). I did this in order to ensure MAC users that dont use extensions can still upload w/o creating a .ZIP or other package.

Question 1: Is my logic sound with regards to approaching this issue, best practices?
Question 2: Will all MAC files return as “application/octect” when not using an extension on MAC, and if so, how can someone determine what type of file it really is? (Note: PDF worked fine when not using extensions on MAC platform).

Thanks in advance.
If code sample is necessary please advise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:23:04+00:00Added an answer on May 28, 2026 at 12:23 am

    Dont use File Extensions to work out MIME Types, instead use “Winista” for binary analysis, see my method here that resorts back to URLMon if winista cant work it out last answer
    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/d79e76e3-b8c9-4fce-a97d-94ded18ea4dd

    Say someone renames a exe with a jpg extension… you can still determine the “real” file format. It doesn’t detect swf’s or flv’s but does pretty much every other well known format + you can get a hex editor and add more files it can detect.

    Edit:
    Download Winista: http://www.netomatix.com/Products/DocumentManagement/MimeDetector.aspx

    This question has given me a great idea, since you wish to append a File Extension that will safely work on MACs and PCs I/you could edit the mime-types.xml file to include safe file extensions that will work to open specific file types on both MAC and PCs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a simple asp .net web form. I want to let the web
I'm writing a simple web form for a client in ASP.NET. The form sends
I have created a simple web form on ASP.NET which includes a DropDownList with
I have a form on a simple web page that has a series of
I have an iPad app that submits orders to an ASP.NET MVC web site
I have a simple web app: a web page with a form to submit,
I have a simple web page that till now didn't need any login. It
I have a simple web service call, generated by a .NET (C#) 2.0 Windows
I have a simple web service that uses an oracle database. When I test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.