Download link for exe files results in “Not Found” error [duplicate]ASP.NET Core - Download .exe returns 404 errorHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How to download a file from a URL in C#?Is there a way to check if a file is in use?Metadata file '.dll' could not be foundFile Upload ASP.NET MVC 3.0Getting the name of the binary file before download in C#Error - Unable to access the IIS metabaseWebDriver: PhantomJSDriver and save file dialogNo EditorOptionDefinition Export Found ErrorUnable to find Use.RunTimePageInfo() method in startup.cs file in aspnet core

Why does this sentence use 东西?

Axial Equatorial NMR graph difference

How were concentration and extermination camp guards recruited?

How can drunken, homicidal elves successfully conduct a wild hunt?

How to skip replacing first occurrence of a character in each line?

Why does NASA use higher frequencies even though they have worse Free Space Path Loss (FSPL)?

What are the words for people who cause trouble believing they know better?

Movie where a boy is transported into the future by an alien spaceship

Does the "6 seconds per round" rule apply to speaking/roleplaying during combat situations?

You've spoiled/damaged the card

Etymology of 'calcit(r)are'?

Do the English have an ancient (obsolete) verb for the action of the book opening

Average spam confidence

What happened to all the nuclear material being smuggled after the fall of the USSR?

Disclosing Spiritual Experiences

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

Why only the fundamental frequency component is said to give useful power?

Traffic law UK, pedestrians

Does Lightning Network has concept of continuous stream of value?

Is it possible for people to live in the eye of a permanent hypercane?

Why don’t airliners have temporary liveries?

Do manufacturers try make their components as close to ideal ones as possible?

Why does Kathryn say this in 12 Monkeys?

Select items in a list that contain criteria #2



Download link for exe files results in “Not Found” error [duplicate]


ASP.NET Core - Download .exe returns 404 errorHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How to download a file from a URL in C#?Is there a way to check if a file is in use?Metadata file '.dll' could not be foundFile Upload ASP.NET MVC 3.0Getting the name of the binary file before download in C#Error - Unable to access the IIS metabaseWebDriver: PhantomJSDriver and save file dialogNo EditorOptionDefinition Export Found ErrorUnable to find Use.RunTimePageInfo() method in startup.cs file in aspnet core






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1
















This question already has an answer here:



  • ASP.NET Core - Download .exe returns 404 error

    2 answers



I have an ASP.NET Core Razor Pages application and want to add a link which downloads an exe file when clicked. Therefore, I added the following code to my Startup class.



Startup.cs



app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1"
);
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

ContentTypeProvider = provider
);


Razor View



<a id="installButton" href="https://mysite.net.au/folder1/install/setup.exe">Install</a>


When I click the link, I get the error below.




Status Code: 404; Not Found




I have also tried using application/vnd.microsoft.portable-executable as the MIME type, but got the same error.



UPDATE #1:
I am aware that this issue has already been posted - I did a lot of searching and reading before posting, but none of the suggested solutions fixed the problem. Hence I needed to post my exact code/situation.



UPDATE #2
There is no button to answer my question so I'll just provide it here:
The only way I could get this working was to add BOTH static file options.
Here is the code that worked:



var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new physicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1",
ServeUnknownFileTypes = true,
DefaultContentType = "plain/text",
ContentTypeProvider = provider
);









share|improve this question















marked as duplicate by Erik Philips c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 16:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I read this post and tried both methods but I keep getting 404 not found. so frustrating - cannot see why it's not working.

    – Ross Kelly
    Mar 24 at 15:32











  • You are right. This was not a duplicate.

    – Volkmar Rigo
    Mar 24 at 15:54

















-1
















This question already has an answer here:



  • ASP.NET Core - Download .exe returns 404 error

    2 answers



I have an ASP.NET Core Razor Pages application and want to add a link which downloads an exe file when clicked. Therefore, I added the following code to my Startup class.



Startup.cs



app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1"
);
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

ContentTypeProvider = provider
);


Razor View



<a id="installButton" href="https://mysite.net.au/folder1/install/setup.exe">Install</a>


When I click the link, I get the error below.




Status Code: 404; Not Found




I have also tried using application/vnd.microsoft.portable-executable as the MIME type, but got the same error.



UPDATE #1:
I am aware that this issue has already been posted - I did a lot of searching and reading before posting, but none of the suggested solutions fixed the problem. Hence I needed to post my exact code/situation.



UPDATE #2
There is no button to answer my question so I'll just provide it here:
The only way I could get this working was to add BOTH static file options.
Here is the code that worked:



var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new physicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1",
ServeUnknownFileTypes = true,
DefaultContentType = "plain/text",
ContentTypeProvider = provider
);









share|improve this question















marked as duplicate by Erik Philips c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 16:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I read this post and tried both methods but I keep getting 404 not found. so frustrating - cannot see why it's not working.

    – Ross Kelly
    Mar 24 at 15:32











  • You are right. This was not a duplicate.

    – Volkmar Rigo
    Mar 24 at 15:54













-1












-1








-1









This question already has an answer here:



  • ASP.NET Core - Download .exe returns 404 error

    2 answers



I have an ASP.NET Core Razor Pages application and want to add a link which downloads an exe file when clicked. Therefore, I added the following code to my Startup class.



Startup.cs



app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1"
);
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

ContentTypeProvider = provider
);


Razor View



<a id="installButton" href="https://mysite.net.au/folder1/install/setup.exe">Install</a>


When I click the link, I get the error below.




Status Code: 404; Not Found




I have also tried using application/vnd.microsoft.portable-executable as the MIME type, but got the same error.



UPDATE #1:
I am aware that this issue has already been posted - I did a lot of searching and reading before posting, but none of the suggested solutions fixed the problem. Hence I needed to post my exact code/situation.



UPDATE #2
There is no button to answer my question so I'll just provide it here:
The only way I could get this working was to add BOTH static file options.
Here is the code that worked:



var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new physicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1",
ServeUnknownFileTypes = true,
DefaultContentType = "plain/text",
ContentTypeProvider = provider
);









share|improve this question

















This question already has an answer here:



  • ASP.NET Core - Download .exe returns 404 error

    2 answers



I have an ASP.NET Core Razor Pages application and want to add a link which downloads an exe file when clicked. Therefore, I added the following code to my Startup class.



Startup.cs



app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1"
);
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

ContentTypeProvider = provider
);


Razor View



<a id="installButton" href="https://mysite.net.au/folder1/install/setup.exe">Install</a>


When I click the link, I get the error below.




Status Code: 404; Not Found




I have also tried using application/vnd.microsoft.portable-executable as the MIME type, but got the same error.



UPDATE #1:
I am aware that this issue has already been posted - I did a lot of searching and reading before posting, but none of the suggested solutions fixed the problem. Hence I needed to post my exact code/situation.



UPDATE #2
There is no button to answer my question so I'll just provide it here:
The only way I could get this working was to add BOTH static file options.
Here is the code that worked:



var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new physicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "folder1")),
RequestPath = "/folder1",
ServeUnknownFileTypes = true,
DefaultContentType = "plain/text",
ContentTypeProvider = provider
);




This question already has an answer here:



  • ASP.NET Core - Download .exe returns 404 error

    2 answers







c# asp.net-core razor-pages






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 3:54







Ross Kelly

















asked Mar 24 at 15:20









Ross KellyRoss Kelly

123210




123210




marked as duplicate by Erik Philips c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 16:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Erik Philips c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 16:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I read this post and tried both methods but I keep getting 404 not found. so frustrating - cannot see why it's not working.

    – Ross Kelly
    Mar 24 at 15:32











  • You are right. This was not a duplicate.

    – Volkmar Rigo
    Mar 24 at 15:54

















  • I read this post and tried both methods but I keep getting 404 not found. so frustrating - cannot see why it's not working.

    – Ross Kelly
    Mar 24 at 15:32











  • You are right. This was not a duplicate.

    – Volkmar Rigo
    Mar 24 at 15:54
















I read this post and tried both methods but I keep getting 404 not found. so frustrating - cannot see why it's not working.

– Ross Kelly
Mar 24 at 15:32





I read this post and tried both methods but I keep getting 404 not found. so frustrating - cannot see why it's not working.

– Ross Kelly
Mar 24 at 15:32













You are right. This was not a duplicate.

– Volkmar Rigo
Mar 24 at 15:54





You are right. This was not a duplicate.

– Volkmar Rigo
Mar 24 at 15:54












1 Answer
1






active

oldest

votes


















2














I tested your code and found the problem. You have to combine the last two UseStaticFiles declarations into one.



app.UseStaticFiles();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "static")),
RequestPath = "/folder1",
ContentTypeProvider = provider
);





share|improve this answer























  • thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

    – Ross Kelly
    Mar 25 at 0:17

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I tested your code and found the problem. You have to combine the last two UseStaticFiles declarations into one.



app.UseStaticFiles();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "static")),
RequestPath = "/folder1",
ContentTypeProvider = provider
);





share|improve this answer























  • thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

    – Ross Kelly
    Mar 25 at 0:17















2














I tested your code and found the problem. You have to combine the last two UseStaticFiles declarations into one.



app.UseStaticFiles();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "static")),
RequestPath = "/folder1",
ContentTypeProvider = provider
);





share|improve this answer























  • thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

    – Ross Kelly
    Mar 25 at 0:17













2












2








2







I tested your code and found the problem. You have to combine the last two UseStaticFiles declarations into one.



app.UseStaticFiles();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "static")),
RequestPath = "/folder1",
ContentTypeProvider = provider
);





share|improve this answer













I tested your code and found the problem. You have to combine the last two UseStaticFiles declarations into one.



app.UseStaticFiles();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings.Add(".exe", "application/octect-stream");
app.UseStaticFiles(new StaticFileOptions

FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "static")),
RequestPath = "/folder1",
ContentTypeProvider = provider
);






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 15:50









Volkmar RigoVolkmar Rigo

6911129




6911129












  • thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

    – Ross Kelly
    Mar 25 at 0:17

















  • thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

    – Ross Kelly
    Mar 25 at 0:17
















thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

– Ross Kelly
Mar 25 at 0:17





thx volkmar. i tried this but it still fails. i've been downvoted as this question already has answers but it does not work for me, so I posted my exact code.

– Ross Kelly
Mar 25 at 0:17





Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현