How can I know when .aspx call is finished? - asp.net

I am building a Flex Application that calls a .aspx page on the same webserver which builds a PDF report using SQL Reporting Services. When the report is built it prompts the user to open or save the PDF.
We are trying to find a way to display a Progress Bar to let the user know that the report they requested is being built, and then destroy the Progress Bar once the report is finished being built.
I've tried opening a new window using JavaScript and trying to catch when the window closes, as well as trying XMLHTTPRequest, but nothing to seems to work.
Does anyone have any suggestions?

There are 2 options:
Use the FileReference class in Flex to programmatically invoke your aspx file. You will be able to track the progress of the call from within Flex by listening to its events. But the users can only save the PDF, not open it.
Have an intermediate HTML page that displays a loading icon and then refresh itself to your PDF generating ASPX page. Encode your aspx url along with parameters etc and set it as a parameter to this intermediate page so it knows what to load.

If you don't have control over the page to be able to put JavaScript on it to hit a URL (or call back to the parent/opener), then you might consider whipping up an aspx page of your own to host a ReportViewer control, and display the report inside of that. This would require you to create a .NET website with a page and a web.config - you wouldn't need to do more than make it receive any parameters your report needs, and it would be do-able via inline-to-the-aspx code as opposed to requiring in-depth .NET knowledge.
Or, you could hit the SS-RS API and render the report directly. Here, you'd craft a URL with parameters for the report on the SS-RS API site to accept. I think, though I don't know for sure, that the SS-RS UI uses the API itself behind the scenes. By default the API is hosted in a site called "reportserver" - you might sniff HTTP traffic while the report is being rendered to get you started with the URL that you'd need to hit.

Another option not mentioned here is to create a .Net webservice, add it to your flex project and when it hits the result handler you know the file is created at that point.

Related

Login to asp.net site from another app, then receive filestream

I have an ASP.NET application with pages that use reportviewer. Can someone give me a hint on how to approach the following requirement:
I want to get the report as PDF file from the page, without user interaction. I know I can render the report to a filestream, but since there's no user opening it in a browser, I need to collect the filestream from another application that might run during the night.
There might be other approaches, like a webservice for example that could return the filestream to me, but this would also mean, I have to modify the setup of the datasources that the report receives it's data from. There are a lot of controls on the page, for supplying filter parameters. By using the page life cycle I can use what's already there.
I thought about wget, but haven't tried it yet, and I'm not sure how complicated logging in will be with cookies. I do have full control over the asp.net application though, so if I can modify something there to make it easier, I'd do it.
You can use the "WebClient" in .net application to get the response from the site.
Please refer the below link:
http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.80).aspx

Using uploadify as part of an asp.net webform?

I have a web form that requires users to fill out some information and upload an image.
What I don't understand:
If I use uploadify to select a file doesn't it upload it right away to the server? Is there a way to defer that until the user would click on a form submit button? Or at least not save it to the file system?
Most examples use a custom HttpHandler for uploading files, but my file upload is part of a form. Should I still use a HttpHandler for that?
Well, I'll try to answer all your many questions, one by one. But before anything, open the official documentation because I will rely on it for answers.
If I use Uploadify to select a file doesn't it upload it right away to the server?
As you can see on the first demo, you can have a anchor (or a button or anything) to trigger the upload start. The Uploadify don't upload nothing until it's done (if the property auto isn't true).
Is there a way to defer that until the user would click on a form submit button?
Like described above, yes. And it's the default way (since the default value of auto is false).
Or at least not save it to the file system?
While the button doesn't trigger the .uploadifyUpload() method, nothing goes to the server. But when the Uploadify starts sending, it will be handled by the server (with the HTTP Handler). The handler is the guy that save it to the file system.
Most examples use a custom HttpHandler for uploading files, but my file upload is part of a form. Should I still use a HttpHandler for that?
As described on the script property, you can point to any server-side language that will handle the HTTP Request containing the data. The HttpHandler is the right thing because it haven't any other processing before or after the code you write. It isn't hard. The official forum shows some samples. And here on StackOverflow we have many questions about it, like these: Getting Uploadify Working in C# and Uploadify not working with ASP.NET WebForms.
The server shouldn't save the file until it is actually actioned by a handler. The Uploadify is providing the UI control for the gathering of the files and feedback. There are some settable properties available to control whether you want the "Auto" upload behavior or not.
You still need some king of server side processing for saving the data and an HTTPHandler is the usual way to do it. The HTTPHandler just operates on what file information it gets from the browser as part of a multi-part form data.
Here is an answer that provides more information about Uploadify: Getting Uploadify Working in C#

File Uploading without page refresh in Web pages

Hii,
Any one knows how to upload files to the physical location of the server. It is possible using file upload control that i know. But i want to avoid the external postbacking of the page. For e.g exactly like what in the yahoo mail did.
In yahoo mail latest version if you attach a file that won't post back and attach that file in to server. What is the technology behind that?
Normally when you submit a form it does a POST request to the server, causing a refresh. Ajax requests get round this by using JavaScript to send the POST data through to the server, and that doesn't need a page refresh.
Ajax requests can't be used to send file data though, so the best way to currently do it is with an iframe hack - you use JavaScript to dynamically build up a form within an iframe, submit that form via JavaScript, and listen for the iframe's onload event. So you know when the form has been submitted. A version of this approach is detailed here:
http://www.webtoolkit.info/ajax-file-upload.html
Other methods to do this would include using a Flash-based solution like http://www.swfupload.org/ or a wrapper like http://www.plupload.com/ - these will prevent you having to roll your own solution and will also provide some extra functionality - upload progress feedback, for example.

Calling web service asynchronously still hangs application

I have an aspx page with three input buttons.
The first button, using javascript/ajax, fires off a call to an IHttpAsyncHandler.
The Handler calls a web service on another server (which generates a report and returns the path to the report file). In the ajax callback, XmlHttp.responseText returns the proper path and a window.open(path) call opens the report, no problem.
The other two buttons open new windows to other aspx pages on the current site.
The problem is, after I click the first button, clicking the other two buttons do not give me the aspx pages until after the report is displayed. Blank windows do pop up, but nothing is rendered until the report is done.
What causes that hang time? I thought calling the report using ajax and an Async handler would not interfere with popping up other aspx pages.
Other attempts:
1. creating a reportGenCompletedEventHandler in the main aspx and calling the service using reportGenAsync(...)
2. calling (in the main aspx)
AddOnPreRenderCompleteAsync(New BeginEventHandler(...),New EndEventHandler(...)
3. calling (in the main aspx)
Page.RegisterAsyncTask(New PageAsyncTask(...))
Page.ExecuteRegisteredAsyncTasks()
4. same as above, creating a separate AsyncHandler, but also creating a separate thread.
Obviously, I'm missing something here. Is it possible to call a web service elsewhere and still have full control of your app?
Thanks
Are the pages you're trying to hit on the same web host? If so, I'm guessing you've hit the "Max 2 concurrent connections to the same host" limit.
The link here on asp.net describes how IE8 lets you go beyond that.

Display loading message and then prompt for open / save

I'm trying to get a page to show a "loading..." message while I create a report and then I'd like to trigger an open / save on the report I've just created.
I can create a static loading page but I don't know how to trigger the open / save dialog.
I could insert an <iframe> but then I would have to save the created report on the server side.
What I'm looking for is a way to just embed the created report into the HTML and let the browser deal with (the report files are Excel and PDF).
Is there a way to do that? I looked at <embed> but it requires a URL, same as <iframe>.
Maybe my best bet is to handle everything in an Http handler and make a first call to generate the report and then do a redirect to display it (and trigger the open / save).
Any ideas?
Are you allowed to use javascript?
You could have javascript on the loading page that either pops up a new window with the report generation or triggers a redirect to the report generation. In the report generation handler you can then set the content-disposition header to force the open/save box.
In the end, I didn't bother with the waiting message. I just point my Silverlight client at the HTTP handler address and wait for it to create it. I had issues with the <embed> tag and the Acrobat Reader plugin (the plugin would time out and not load the report when it was ready) but that doesn't happen at all when the browser waits for the page to load.
So, not an answer but it works.

Resources