Blog

Filter posts by Category Or Tag of the Blog section!

Different file extensions in asp.net core

Friday, 03 August 2018

In my earlier related post to this subject, I wrote that there is config in asp.net core to enable the static file access but that's not Ok for every sort of file, for example, you can't access to an APK file in your directory. In order to that, you can use FileExtensionContentTypeProvider class like this:

 

var contentTypes = new FileExtensionContentTypeProvider();

            contentTypes.Mappings[".apk"] = "application/vnd.android.package-archive";

            app.UseStaticFiles(new StaticFileOptions

            {

                ContentTypeProvider = contentTypes

            });

 

Needless to say, this configuration should be placed in the Configure method:

    

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)

        {

        }

Category: Software

Tags: Asp.Net

comments powered by Disqus