Asp download file from server






















I'd like something like the following, but that will allow me to pass a web URL, and not a server file path. I may have to end up building my file path from a config base path, and then append on the rest of the path, but hopefully I can do it this way instead. You could use HttpWebRequest to get the file and stream it back to the client. This allows you to get the file with a url. An example of this that I found but can't remember where to give credit is.

I do this quite a bit and thought I could add a simpler answer. I set it up as a simple class here, but I run this every evening to collect financial data on companies I'm following. If you want to do something different with the stream instead you can easily change this.

Not sure if this is the case everywhere, but I figured I'd add it. Also, I removed. Response in place wherever resp was referenced. Your code is working fine. I have checked it. Top Rated Most Recent. Accept Solution Reject Solution. Posted Aug am RajeeshMenoth. Though the post is very old, submitting for any new user having the same kind of issue: If your problem is just "not getting the dialog box", then it's browser dependent and if it's already checked as 'Do not ask again' kind of selection, it wont appear again.

You need not worry about this. Same code may download the files for another user with dialog box with save button. Check it in different browser ie. Chrome and Firefox. Posted Feb am Suresh Madhavaraju. Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account. This email is in use. Do you need your password?

Note : Name on input elements must match action parameter name or model property name for model binding to work. This is no different than model binding of simple and complex types. Action method needs to return FileResult with either a stream , byte[] or virtual path of the file. You will also need to know the content-type of the file being downloaded. After a user clicks a button, I want a file to be downloaded. I've tried the following which seems to work, but not without throwing an exception ThreadAbort which is not acceptable.



0コメント

  • 1000 / 1000