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 8460413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:36:02+00:00 2026-06-10T13:36:02+00:00

In .NET resource files, various types of content can be inserted – from plain

  • 0

In .NET resource files, various types of content can be inserted – from plain text to images, the latter being represented as base64 encoded byte array (at least it looks like that in the resx file).

My purpose is to be able to list the resources within the application and to display additional information like the content (MIME) type, size (in bytes) and etc. I need to group by and sort/filter the resources by the content type.

My question is – is it possible to retrieve the proper MIME type of the resource item. For instance if I have stored a JPG image within the application resources, I’d like to have its content type as image/jpeg. If I have stored a JSON text, I’d like to have its MIME type saying application/json.

Is it possible to do this by the means of the .NET standard resource management capabilities?

  • 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-06-10T13:36:03+00:00Added an answer on June 10, 2026 at 1:36 pm

    I have read a number of related questions for MIME type retrieval. Most of the situations were related to working with a physical file. In the resources scenario, however, this is not always the case, because getting a resource by name returns an object that can be almost anything. Additionally, determining mime-types based on the binary representation of an object has additional notable drawbacks 1) it does not guarantee correctness for similar types (.docx files might be wrongly recognized as application/zip) or to cause performance degradation as they require to process the objects bytes.

    So, I figured that the one who defines the resources is responsible for what content type they are representing. Therefore I decided to define mime-type mapping based on resource set name and resource name which is part of the application configuration. This will cause additional effort to add content-type description as new resources are added, but is easy enough to manage and does not require rebuilding the application.

    For example a custom configuration section with the following contents could do the job:

    <resourceContentTypeMapping>
        <resourceSet name="CommonResources" defaultContentType="text/plain">
           <!-- This would map enties in CommonResource.resx file -->
           <item key="AppIcon" contentType="image/jpeg" />
        </resourceSet>
    
        <resourceSet name="SomeOtherResources" defaultContentType="text/plain">
            ...
        </resourceSet>
    
        ...
    </resourceContentTypeMapping>
    

    The defaultContentType attribute determines the content type returned for all unmapped resources. Since most items in resource files are strings, I decided that text/plain will ease my job as I will need to describe non-textual resources only. Grouping into resource sets allows for uniquely describing a resource item from a single resx file.

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

Sidebar

Related Questions

I've just moved my resource files (javascript, css, images) from Content folder to custom
how i can send sms from asp.net?any idea about it?or any resource through which
I have a .net application that currently has resource files for all it's content,
In my asp.net mvc project all text is in resource files, and in view
In ASP.NET, an application can be localized using resource files. Resource files hold different
Does Java have an equivalent to .NET resource (.resx) files for localization? In .NET,
When reading our configuration and resource files, our .Net system currently just does ConfigurationManager.AppSettings[keyToFind]
I'm trying to convert an ASP.NET web application to use resource files. I haven't
I have project asp.net with namespace test and I'm using resources (files Resource.resx and
In .Net, When I fetch a resource from a resx in an external resources

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.