EdgeDoc
Features
Tech Specs
How-to C#
Pricing
Open a File from a URL (HTTP, FTP)
  |  
Home ›› XDoc.HTML5 Viewer ›› C# Viewer: Open a File from a URL (HTTP, FTP)

C# HTML5 Viewer: Open a File from a URL


How to Open a File from a URL (HTTP, FTP) and Show It on Your HTML5 Viewer






RasterEdge XDoc.HTML5 Viewer SDK for .NET enables C# users to open a document to view online from a URL (HTTP, FTP). A simple API CreateWebDocFromOnLine(string src, string fileName); can help with this. Here, src represents the URL of your target file and fileName is used to let your C# viewer show the name of this file (if it is "", HTML5 viewer control will charge by the URL.).




C# Tutorial: Open a File on Viewer from a URL



File opening from URL is well supported by RasterEdge XDoc.HTML Viewer. To use this function in your C# web program, you can add ?src=http://... to the address bar of web browser, or choose to use it via button click. If button click is preferred, you need to add the following code to your Default.aspx.




var _tabFile = new ToolbarTab(File);
_tabFile.addCommand(new RECommand(openOnlineDoc));
_viewerTopToolbar.addTab(_tabFile);




Moreover, please use the code below in your Default.aspx.cs to enable your C# project document viewer to control file opening from URL.




private void RequestServerceHandler()
{
        string command = Request.Form["RECommand"];
        if (command == null || command.Equals(""))
        {
                if (Request.Form["src"] != null)
                LoadFileFromOnline();
        }
}

public void LoadFileFromOnline()
{
        string src = Request.Form["src"];
        REWebDocument webDoc = REDocumentControl.CreateWebDocFromOnLine(src, "");
        REDocumentControl.ResponseToClient(webDoc.MsgToClient, Response);
}