How to allow powershell to download an EXE from a .net core MVC web app?


I have a .net core MVC web app that depends on a .net framework console app. When the Core app builds, so too does the console app and I get the exe in the bin directory:

<a href="https://i.stack.imgur.com/Bv1eM.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/Bv1eM.png" data-original="https://i.stack.imgur.com/Bv1eM.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

This is working great, however now I need to provide an endpoint through the web app that allows anyone to download the EXE (the intent is to allow a powershell script to download the exe via an endpoint).

How can this be achieved?

I understand the following can be used to actually download the file:

Invoke-WebRequest http://localhost:8080/download/tokenizer.exe -OutFile c:\download\tokenizer.exe

However I don't know how to get the exe accessible. I believe I need to move the EXE from the bin to some directory that I then configure as being publicly accessible, but I'm lost on the details here.


By default ASP.NET Core static files middleware will only serve content types that it understands. Unknown file types will return a 404.

The middleware can be configured to serve unknown file types, however it is safer to add your own content types explictly:

var provider = new FileExtensionContentTypeProvider(); provider.Mappings[".exe"] = "application/vnd.microsoft.portable-executable"; app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider, });


.Net Core applications serve static files from the wwwroot directory (you can see this configured in Startup.cs).

To serve a static file, you need to copy it there.


  • GCM push notification with C# asp.net giving null as notification in android devices
  • How do I connect to the Asana Rest API using c#?
  • Selenium ChromeDriver (C#) Crashes Only in Visual Studio Debug Mode
  • .Net Compact Framework 3.5 HTTP POST
  • Find duplicate values in one of the two columns in a text file
  • Azure Resource Template Deployment issues
  • powershell: script to start a program with parameters?
  • In powershell, using the export-csv cmdlet, my ints are being encapsulated by quotes any idea why?
  • Send data from edittext to listview
  • Should a web service response include empty values?
  • Making Google Visualization - Annotation Chart to work in GWT
  • How can go in last activity with resume button?
  • Execute scripts AJAX returns
  • Check for zero lines output from command over SSH
  • Android application: how to use the camera and grab the image bytes?
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • What and where is mdimport
  • How to match http request and response using Jersey ContainerRequestFilter and ContainerResponseFilt
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • JQuery Internet Explorer and ajaxstop
  • Use of this Javascript
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • How to install a .deb file on a jailbroken iphone programmatically?
  • DomPDF {PAGE_NUM} not on first page
  • Using jQuery closest() method with class selector
  • Javascript simulate pressing enter in input box
  • Array.prototype.includes - not transformed with babel
  • Importing jscolor library in angular 2
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • A cron job substitute?
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Why joiner is not used after Sequence generator or Update statergy
  • coudnt use logback because of log4j
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy