csv file upload on asp.net - c#

User need to upload 30,000 csv values, these values may contain 16 digit numbers or zipcodes.
Now our asp.net project doesn't use AJAX tool kit controls or jquery or any other 3rd party controls or open source code. This is restriction as per companies privacy policy.
So I have to come with a best way to accommodate file upload feature. This has to be versatile in regards to re-usability some thing like a custom control
This file upload feature should not be saved on the server, instead I need to read data into stream buffer and send them to UI then once user verify these values he/she'll have to hit submit thus values will be saved to DB.
what are the best ways to implement this,
Can I make use of System.Net.Webclient? or
Is there any other alternative ways by using Async HttpHandlers?
Can I show file upload progress to UI ?
Appreciate if you could help me with proper guidence on this.
Thanks in advance
krish

Well 30,000 values of zipcode or any other 16 digit code should be uploadable normally using file control(i mean via postback).
if you have to read and show 30,000 on the UI, i presume you are at risk of freezing your UI.
Moreover if you are not on HTML5, there is no way that you can read the content on the client side, except if you fiddle around with flash.
HTML 5 file api reference
http://www.html5rocks.com/en/tutorials/file/filesystem/
How to read and write files with Flash(Action script)
http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/

Related

Play mp3/wav file from memorystream to webpage

Recently I was approached to develop an application (asp.net/c#) to allow users to listen some audio files stored in some shared folders.
The users didn't have access to the shared folders, and the files should be streamed. Also, the page should provide the play/stop/pause/forward/back functions, as well as time elapsed/total time information.
So I setup a webservice that access the required file, and return a Byte[] containing the mp3/wav audio (actually I have to convert them to the desired mp3/wav format prior to returning the Byte[]).
The problem is that I have no idea on how to present it in the webpage.
What i need is a webpage with some control that provides the necessary functionalities and information, loaded from a Byte[].
I've researched the web and tried a lot of snippets and controls with no luck at all.
Any ideas or directions on how to implement it?
Thanks in Advance,
António
You could use HTML5's audio tag, if you expect your users to be using fairly recent browser versions. You'd set the src to a URL that would be set up to write your byte[] to the response stream (e.g. maybe store the byte[] in Session, make an .ashx handler page to return that, and set src="myHandler.ashx").
A good approach would be to use silverlight or flash player, even a java applet.

Sending PDF with Fast Web View in ASP.NET

I am using ASP.NET 4.0 + IIS 7 to serve up a number of large PDFs via Response.TransmitFile.
The PDFs are all linearized, i.e. "Fast Web View". However the browser still requires the entire PDF to be downloaded before displaying any of it. All I want to do is show the first page (at least) without having to wait several minutes for the entire PDF to download.
From what I have read, the response header should include ["Accept-Ranges", "bytes"] but this does not seem to help.
Can anyone give me some pointers?
Thanks in advance!
I don't think you can do that easily. For byte range to work you would need many requests to serve the same file. How would you associate all these requests with a single file instance? You would probaly need to save the file to disk or somehonw maintain the file in memory... it could get tricky...
Much simpler would be to save PDFs in a shared folder (a first in first out cache) and let the HTTP 1.1 do the rest.

Server-side printing in C#/ASP.NET

On the server that my application is being run on, a virtual PDF printer is being installed (don't know much about this yet, except it's from Adobe), and my application needs to use this 'printer' to create PDF's from HTML pages (a GridView mostly), and then redirect the user to the URL of the where the PDF is stored.
I've been looking at the PrintDocument object in System.Drawing.Printing, however I've read that you can't simply feed this a HTML page. What are my choices? The easiest option would be to be able to 'print' a given HTML page (choosing what and what not to print using CSS), but from what I've read this is fairly difficult, so I'm thinking about somehow constructing whatever object PrintDocument needs programatically, if that makes sense.
Any ideas on how I should do this?
there are some free/cheap libs for creating pdfs on the fly. I've used itextsharp before and it worked pretty well. Takes a bit of time to get up to speed in how it works but I'd suggest checking it out.
There are also printing services like Neevia DocConverter that will monitor a folder and auto convert whatever you put in the folder to a pdf, jpg, etc. you can set it up so that if you drop a url shortcut in the folder it will render the webpage at that url to pdf. it's a bit more of a pain if you want to do realtime rendering but works excellent for generating mass reports in batches that you want to post up to a website or email later.

Asp.net fileupload transfer rate

Is there any way to easly know Transferrate between server/client during un filupload upload? Because uploading a file of 4,13Mb take about 5 or 6 minutes.... Is there anyway we can track it, by writing it in flatfile, email, response.write anything!! We're stuck.
Thanks to help us :(!
Not if you're using the built-in asp:FileUpload control. Some third party AJAX-based upload controls probably do this, but I don't know of any offhand.
Not easily.
HTTP works this way: you send ALL data and, after that, server begins to process your request.
But you can write some client code (flash, applet, silverlight) which break a file in pieces and send them, one at time, to server. This way you can compute your transfer rate.
Use a flash upload tool like SWFUpload, by which you can detect the upload speed, and then send the total time/speed to the server once the file is done.

How do CMS upload images?

I am just playing around and trying to make a very simple CMS. Right now I what I do right now is I use "FtpWebRequest" to get the file that they want to change around and stick it into a jquery plugin call html area(rich html editor).
Now I am wondering how could I allow them to add images that are not already hosted? Ie not on imageshack or something.
I am guessing I need to somehow upload the file and then store it somewhere but not sure how to do all that.
Thanks
A common approach for CMS systems that need to work in low-trust environments (like shared hosting) is to use the FileUpload control, and save the uploaded file as a binary (BLOB) in a database. This avoids dealing with the headache of disk access rights on the web server.
If you're using SQL Server, here's a great article on the database side of things (storing images as BLOBs).
The .NET side of things is pretty straightforward. The FileUpload.PostedFile property has all the information about the uploaded file, including a byte stream of its data.

Categories