ZIP file download tries to download page - asp.net

just putting this out there to see if anyone has any good off-the-cuff suggestions.
I have a web page with a button that triggers the download of a PDF file. When I run this page up in development from within VS I get the file coming back for download as expected, however since moving my web site to a staaging environment it is now yielding a very different result: When I click the download button I instead get an error and a message which seems to indicate that the call actually attempted to download the raw ASPX page rather than any ZIP file.
As this works so painlessly in my development environment, I'm assuming this must be down to environmental/configurational differences. Has anybody come across this before and if so could you inform me of the error of my ways?
Many thanks in advance
Ian

Could the aspx file be the actual zipfile ? Have you tried downloading it and open as zip?
Does the server allow for aspx to execute, eg mime-settings ?
Maybe this helps Filename and mime problems - ASP.NET Download file (C#)
Or look here How to retrieve and download server files (File.Exists and URL)

Related

Is there any feature is providing the microsoft teams to load static web pages(html/aspx) in browser

I am trying to upload the html file and aspx file in teams. once it is loaded then get the copy of files address
and i am going to load that copied path url in browser but it is not showing web content which i design like web page.
in browser (html/aspx) files are downloading. If i am trying to load apsx file in browser it was showing like error(Something went wrong File Not Found),
so want i like is that is there any feature to load in browser?
Thanks for your detailed explanation.
First of all, Teams does not host any html or aspx file itself. So you can not upload a file and use the URL to render web page in browser. The file URL is a link to that uploaded file location. That's the reason the file is getting downloaded in browser.
Secondly, it is other way round. You can run your website in any other server and use that URL to configure a tab in MS Teams.
Please go through these links
What can Teams apps do?
How do tabs work?

RobotFramework: Test that a download link works

I have a web page that i need to click a download link of. Ive got this far and i can see manually that the file is downloaded. How do i (in Robot) verify that the file is downloaded correctly on this?

is it ok to read aspx/cshtml files that are also used by the asp.net

I want the user to be able to see the source code of the page that he is on, so I'm planing to just read the file from the file system (Server.MapPath("~/Views/home/index.aspx")) and output it into html.
I'm just wondering if there is any problem with this approach, like if the asp.net process is locking the aspx/cshtml files or something like that
This is perfectly alright.
Asp.net does not lock onto the aspx files.
It reads these files on first request, and stores in a format it IL format compiled code, and from then on only watches the original aspx for changes.
If the file changes it is recompiled.
Ref: dynamic compilation
I could not find any docs to support this, but you should have no trouble if you read the aspx file.

browser Does not open 'Save file' dialog box

I have uploaded a file on server and given a link to that file (test.txt file say) in my asp.net page. when i click on this link, it opens the content of that text file within the browser. But i want to open a dialog box so that user can save it on his local machine.
More over if file is dll type then it gives 404 error(file not found).
I tried it out in IE and Firefox and also its working fine on my local IIS but not on Server machine.
There are various ways suggested of forcing a file download to the browser in ASP.Net, and lots of examples ("asp.net file download"). Here's one: http://aspalliance.com/259
Basically, what you'l need to do is transfer the file to the browser 'in code' using Response.WriteFile() or something similar.
You'll also need to set a couple of response headers so that the browser knows this is a download as opposed to a file it should try and load: Content-Type and Content-Disposition
Personally, I'd rather zip a DLL if it is to be downloaded - after all a DLL is executable code, and could be blocked at the client side.

How do I download an msi file via an asp.net button?

So, I've created my wonderful winforms app that I want to unleash upon the world, and now I am trying to create a simple website to host some basic information and link to the setup file (msi installer file )....
I have a button on the asp.net page and the setup file setupApp.msi in same folder as the asp.net page. I am currently trying the following:
Response.Redirect("http://./SetupApp.msi");
But this best guess at what to do is not working. Is there something wrong with Mime types here? What do I need to put in the click event to allow users to download this file?
The path you are passing in to the method is not valid (there's no server name called ".").
You can pass in a relative path and it should work fine because ASP.NET will resolve the path:
Response.Redirect("SetupApp.msi")
Or if it's not in the same folder, try one of these:
Response.Redirect("../Downloads/SetupApp.msi")
Response.Redirect("~/SomeFolder/SetupApp.msi")
Keep in mind that you don't necessarily have to do the whole redirect at all. Instead of writing code in an ASPX file you could just have a link to your MSI:
Download my app!

Resources