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 Hy开发者_如何学编程perlinkButton 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
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.
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!
精彩评论