views:

253

answers:

1

I have an SL3 application that needs to be able to pass an image to the server, and then the server will generate a PDF file with the image in it, and display it to the user.

What I already have in place are the following:

(1) Code to convert image to byte array (2) Code to generate PDF file with image

The main problem that I am running into is the following:

In order to bypass the pop-up blocker, which is a requirement for my application, I am using the following code:

var button = new NavigationButton();

button.NavigateUri = new Uri("http://localhost:3616/PrintReport.aspx?ReportIndex=11&ActionType=Get&ReportIdentifier=" + reportIdentifier.ToString() + "");

button.TargetName = "_blank";

button.PerformClick();

Initially, I would pass the image to a WCF web service (as a byte array), and then "navigate" to the ASP.NET page that would display the report. However, if I do this, then I can not use my custom HyperlinkButton class, and, certain browsers, including Safari, will block a new window from opening up. Therefore, it appears that the only option is to use the HyperlinkButton class.

What I need to be able to do is to somehow pass the image, as a byte array or some other data type, to the server, such that it can temporarily store the image, even if it is in a server variable, and then immediately retrieve it when I navigate to the PrintReport.aspx page.

If I upload the image to an ASP.NET form and then use the HyperlinkButton class to navigate to the PrintReport page, it doesn't work, as the app navigates to the PrintReport page before the system has finished uploading the image. I can't pass it to a web service, as that would require that I navigate to the PrintReport.aspx page in the callback code of the web method that I would be passing the image to, and the HyperlinkButton will not allow that, based on security rules.

Any help or ideas would be appreciated.

Thanks.

Chris

+1  A: 

Is sounds like your problem is less to do with the image upload, and more to do with using only one click to upload and navigate to the page the report is displayed on, if that is the case, then handling the image upload on the reports page itself might be the way to go.

http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data

shows how to upload to a standard aspx page

As for getting the webservice approach working, I'd say the piece of the jigsaw you're missing here is WCF ASP compatibility mode.

This enables you to access the httpcontext in a wcf service. The catch of course is that you're coupling your service to ASP....

Take a look here http://blogs.msdn.com/wenlong/archive/2006/01/23/516041.aspx for more details on ASP compatibility mode.

Your process then becomes:

Upload to Webservice -> add to cache

Navigate to page -> Retreive from cache

hope one of these suggestions helps

if not, get back to me!

Overflow
Your understanding is correct.If I upload to a web service, then the logical approach would be to navigate to the page that displays the report once the upload of the image data is complete. You can't use the HyperlinkButton Navigation method from a callback method etc... Something to do with security measures in Silverlight.So, I am still stuck trying to figure out how, with one click, to upload the image data AND using HyperlinkButton, open a new window and browse to another page.
Chris
K, I'll look into AutomationPeers namespace... This allows you to simulate user action (again the security may mean there isn't an automationpeer for hyperlink button)... It looks like you'll have to do something fancy serverside, not let the reportpage render until the image is fully uploaded...I'm at work at the moment and don't have a silverlight dev env, but when I get home I'll give this a shot and let ya know.
Overflow