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;
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
);
c# asp.net-core razor-pages
marked as duplicate by Erik Philips
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.
add a comment |
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
);
c# asp.net-core razor-pages
marked as duplicate by Erik Philips
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
add a comment |
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
);
c# asp.net-core razor-pages
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
c# asp.net-core razor-pages
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
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
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
);
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
);
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
add a comment |
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
);
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
add a comment |
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
);
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
);
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
add a comment |
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
add a comment |
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