browser Does not open 'Save file' dialog box - asp.net

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.

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?

Accessing WebDav from Server Link

I've downloaded the .Net Server and ajax library
We need to be able to edit documents directly from the WebDav Server.
I've succeeded doing so with the javascript code using MicrosoftOfficeEditDocument and JavaEditDocument
I'd like to be able to have in my pages a link as follows
\server\DAV\path\file
When I place a similar link like above, it doesn't open the file. When I copy link and place in windows run command, it opens
Is it possible to have direct links to webdav storage files for opening?
Also, Is there a planned solution for the jar file running in Chrome?
I've followed the instruction for https://java.com/en/download/faq/chrome.xml#npapichrome
This allows chrome to load the jar file, but They say they stop supporting.
To open a document from a web page your link must be HTTP or HTTPS, that is start with http://server/. It would not work with a network path.
In your case URL must look like http://server/DAV/path/file.ext

Can I use a custom logo for downloaded url files?

My site has an option to download a shortcut (.url) file onto the user's PC by clicking a link. The idea is that users then can save this to their desktop, and use it a shortcut to the site for future visits. (I know it's wacky, but it's what my client wanted.)
I have an icon(.ico) file that I wish to use, but whenever the user downloads the file the icon is not shown.
I've tried opening the URL file in notepad and editing the IconFile value to point to the icon file on the server itself.
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://example.com/
IDList=
HotKey=0
IconFile=http://example.com/favicon.ico
IconIndex=0
However this does not seem to work. Can anyone suggest what might be wrong, or how I can fix it.
MS Windows does not load icon files specified with ´IconFile´ from the internet (for security reasons, I guess).
Rather it only loads the ´IconFile´ from
local file if the path is a file path, or
local web cache if the protocol is http:
You can verify this by navigating Internet Explorer to http://example.com/favicon.ico (now file is in cache) and then refreshing your *.url file (by right-clicking -> Edit -> [Make a fake change])
Now the icon should be displayed. Now clear your IE-cache, refresh *.url file, and the icon is gone (replaced by the icon of the default browser)
So,
either your client can tolerate that the default icon is displayed if icon is not cached, or
you have to provide a local copy.

Force file download in a browser using ASP.Net MVC when the file is located on a different server without downloading it on my server first

Here's what I would like to accomplish:
I have a file stored in Windows Azure Blob Storage (or for that matter any file which is not on my web server but accessible via a URL).
I want to force download a file without actually downloading the file on my web server first i.e. browser should automatically fetch the file from this external URL and prompts the user to download it.
Possible Solutions Explored:
Here's what I have explored so far (and why they won't work):
Using something like FileContentResult as described here Returning a file to View/Download in ASP.NET MVC to download the file. This solution would require me to fetch the contents on my server and then stream from my server to the browser. For this reason this solution won't work.
Using HTML 5 download attribute: HTML 5 download attribute would have worked perfectly fine however the problem is that while it is really a very neat solution, it is not supported in all browsers.
Changing the file's content type: Another thing I could do (at least for the files that I own) to change the content type property of the file to something that the browser wouldn't understand and thus would be forced to download the file. This might work in some browsers however not in all as IE is smart enough to go beyond the content type and sees the file's content to determine the content type. Furthermore if I don't own the files, then I won't have access to changing the content type of the file.
Simply put, in my controller action I should be able to specify the URL of the file and somehow browser should force download the file.
Is this something which can be accomplished? If yes, then any ideas how I could accomplish this?
Simply put, in my controller action I should be able to specify the URL of the file and somehow browser should force download the file [without exposing the URL of the file to the client].
You can't. If the final URL is to remain hidden, your server must serve the data, so your server must download the file from the URL.
Your client can't download a file it can't get the URL to.
You can create file transfer WCF service (REST) which will stream your content from blob storage or from other sources through your file managers to client browser directly by URL.
https://{service}/FileTransfer/DownloadFile/{id, synonym, filename etc}
Blob path won't be exposed, web application will be free from file transfer issues.

How to display a XDP pdf file in browser like how normal PDF file open?

I have a XDP file that Acrobat can open. It contains a PDF plus some data to fill in the form fields in the PDF.
In my HTTP request header I set
content-type to "application/vnd.adobe.xdp+xml" and
Content-Disposition to "in-line"
still my browser downloads the file and asks me if I want to Open it or save it. When I click on Open it loads the PDF form and data inside Acrobat, not in the web browser.
Do you have any idea?
UPDATE:
I reinstalled the Adobe plugin and now browser(FireFox) attempts to open the PDF but I get the following error:
that is very strange as the file is created by Acrobat it self. On the same page that throw this error, if I press OK and go to File > Save as.. and save the XDP file on desktop then drag and drop it into a new browser window, it opens it! and the address bar shows a very similar file name and location as was shown in the error (temp directory of FireFox cache).
It looks like an administration problem. Your file is being downloaded but Adobe doesn't have the access rights to that folder.
Contact your network administrator is my only answer.
I wonder if this open source project will solve your web display problem: pdf.js If not immediately, perhaps you can help it along.

Resources