Download - Out Of Browser

Dec 29, 2010 at 1:17 PM

I've tested the download control that runs correctly on the "In Browser" mode.

When I switch the application in the "Out of Browser" mode the Download control remain opened...

Does the Download Interlink control support the "Out of browser" funtionality ?

Thank you!!

Coordinator
Dec 29, 2010 at 1:18 PM

Sorry it does not… I’m working on adding support for OOB. No ETA though…

Mar 28, 2011 at 10:04 AM

Hi, thank you for this great project. I tested the QuickStart Tutorial in Web mode and it's working great.

With OOB mode, I have got an HTML Bridge COM error. I don't know where changing AbsoluteUri ; iI tried in web.config for HttpHandlers : Path="http://localhost:52878/FileDownload.ashx" but it doesn't work.

Have you got an example please ?

 


Coordinator
Mar 28, 2011 at 5:44 PM

An absolute uri for the DownloadUri property is required for OOB support.

string fileName = "serverSideFileName"; // The file to download from the server
var ddialog = new DownloadFileDialog(saveFileDialog.SafeFileName, saveFileDialog.OpenFile(), fileName);
ddialog.DownloadUri = http://yourwebsiteurl/filedownload.ashx
ddialog.Show()

Let me know if you have any other issues...

Mar 28, 2011 at 6:33 PM

Sorry, it doesn't work. The absolute uri is working for "In Browser" mode but not in OOB for me.

 

Could you confirm also that Interlink can upload a large file in OOB ?

I red that's not possible from WCF because Stream is transform to Byte[], and streamedResponse is not permited for upload.

 

 

 

Coordinator
Mar 28, 2011 at 9:00 PM

1. This does not use WCF.
2. In Browser does not require an absolute uri (assumes relative to your site), only OOB requires this as it cannot derive the full URL to the .ashx HTTP Handler.

If you follow the quick start example including the web config, and then specify the absolute uri to your web server, everything should work fine OOB. Have had several users to do this so I know it works.

Side note: If you are running in IIS or have your app running as a sub-app, then you may have to modify the URL to the HTTP handler to include the sub-app. Example: http://yoursite/yourapp/fileupdload.ashx versus http://yoursite/fileupload.ashx HSS Interlink assumes the latter.

Also, where people get tripped up is the difference between the "HTTP" Handler and the "File" Handler. The HTTP Handler is not a physical file. It's merely a web config setting that says any request for the "FileUpload.ashx" that is specified in the web config, to use the FileUpload (HTTP Handler) from HSS Interlink. Then HSS Interlink (using the app config setting) calls your "File" Handler, which allows you to implement your own upload or download processing as necessary.

Let me know if you still have issues. if you do, please provide your sample app and web config, and I can usually get you on track in a very short turn time.

Mar 29, 2011 at 12:45 PM

Ok, i provide my code.  (I don't post handler code because i followed the tutorial).

You can see inside MainPage.xaml.cs the specification of downloaduri (and uploaduri too) : http://localhost:49391/FileDownload.ashx.

My project is working "In-Browser" whithout Absolute Uri for both Download and Upload.

My project is working "In-Browser" whith Absolute Uri for Download, but not for Upload.

My project is not working "Out-Of-Browser" whith Absolute Uri for both Download and Upload.

Thanks you.

 

Web.config :

<configuration>
    <appSettings>
        <add key="UploadHandler" value="TestInterlink.Web.UploadHandler, TestInterlink.Web"/>
        <add key="DownloadHandler" value="TestInterlink.Web.DownloadHandler, TestInterlink.Web"/>
    </appSettings>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpHandlers>
            <add verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
            <add verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
        </httpHandlers>
    </system.web>

</configuration>

 

 

MainPage.xaml.cs : 

        private void Upload_Click(object sender, RoutedEventArgs e)
        {
            UploadFileDialog udialog = new UploadFileDialog();
            udialog.UploadUri = "http://localhost:49391/FileUpload.ashx";
            udialog.BrowseAndShow();
        }

        private void Download_Click(object sender, RoutedEventArgs e)
        {

            string fileName = "folder.png"; // The file to download from the server
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            //saveFileDialog.Filter = "All files (*.*)";
            if (saveFileDialog.ShowDialog() == true)
            {
                var ddialog = new DownloadFileDialog(saveFileDialog.SafeFileName, saveFileDialog.OpenFile(), fileName);
                ddialog.DownloadUri = "http://localhost:49391/FileDownload.ashx";
                ddialog.Show();
            }
        }
Coordinator
Mar 29, 2011 at 2:08 PM

From the demo site, here is a snippet of where I toggle the Uri based on whether IB or OOB. This is in the constructor of MainPage.Xaml.cs

if (Debugger.IsAttached || (Application.Current.IsRunningOutOfBrowser || !System.Windows.Browser.HtmlPage.IsEnabled))
{
	defaultUploadUri = "http://localhost:15406/fileupload.ashx";
	defaultDownloadUri = "http://localhost:15406/filedownload.ashx";
}
else
{
	defaultUploadUri = UploadFileDialog.DefaultUploadUri;
	defaultDownloadUri = DownloadFileDialog.DefaultDownloadUri;
}

Below is the source code from the demo site for downloading a file...

void DownloadFile()
{
	if (null == this.dtgFiles.SelectedItem)
		return;

	if (this.dtgFiles.SelectedItems.Count > 1)
		MessageBox.Show("You have more than one file selected, only the first file will be downloaded.", "HSS Interlink", MessageBoxButton.OK);

	TestClient.Web.InterlinkFile file = this.dtgFiles.SelectedItem as TestClient.Web.InterlinkFile;
	if (null == file)
		return;
	string ext = Path.GetExtension(file.FileName);

	SaveFileDialog saveFileDialog = new SaveFileDialog();
	try
	{
		saveFileDialog.Filter = "All files (*.*)|*.*|File (*" + ext + ")|*" + ext;
		saveFileDialog.FilterIndex = 2;
		DownloadFileDialog ddialog = null;
		if (saveFileDialog.ShowDialog() == true)
		{
			var hexColorString = ((ComboBoxItem)this.cboBackgroundDownload.SelectedItem).Tag.ToString();
			ddialog = new DownloadFileDialog(saveFileDialog.SafeFileName, saveFileDialog.OpenFile(), file.FileName);
			ddialog.Completed += new EventHandler<DownloadCompletedEventArgs>(ddialog_Completed);
			ddialog.DownloadUri = defaultDownloadUri;
			ddialog.Title = this.txtTitleDownload.Text;
			ddialog.IsTitleImageVisible = this.chkShowTitleImageDownload.IsChecked.Value;
			ddialog.Background = this.GetColoredBrushFromHexString(hexColorString);
			ddialog.Show();
		}
	}
	catch (Exception ex)
	{
		MessageBox.Show(ex.ToString());
		Debug.WriteLine(ex.ToString());
	}
}

void ddialog_Completed(object sender, DownloadCompletedEventArgs e)
{
	var ddialog = sender as DownloadFileDialog;
	ddialog.Completed -= new EventHandler<DownloadCompletedEventArgs>(ddialog_Completed);
	if (null != e.Error)
	{
		MessageBox.Show(e.Error.Message);
	}
	if (e.Canceled)
	{
		MessageBox.Show("Download canceled.");
	}
}
This is the webconfig...
<appSettings>
	<add key="UploadHandler" value="TestClient.Web.UploadHandler, TestClient.Web"/>
	<add key="DownloadHandler" value="TestClient.Web.DownloadHandler, TestClient.Web"/>
</appSettings>
<system.web>
	<compilation debug="true" optimizeCompilations="true" targetFramework="4.0"/>
	<httpHandlers>
		<add verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
		<add verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
	</httpHandlers>
</system.web>
This works like a charm everytime. No issues.
Beyond this, it may be an environmental issue. A way to help narrow down where the problem is happening is to confirm that your File Handler is at least being called.
I typically confirm this by putting a break point in the constructor. If it hits there, then you know that Interlink is getting to your file handler on the web server.
If it doesn't get there then I would start a new project from scratch, following the QuickStart including the prerequisites.
If you want, you can zip up of your test project and send it to me and I can take a look.
Mar 8, 2012 at 12:11 PM

Hi,

I am also facing this issue can you please provide the solution for issue?

 

Thank

Raj

Coordinator
Mar 8, 2012 at 4:00 PM

Not sure what the root cause of your issue. Everyone that I've worked with, it ended up being their environment.

Can you provide more details as to your situation?