.Net - error in .Stream Method

Hi there,



I have the following URL:

https://www.infoportal4.com/demoserver/docs/~D1406?version=1000000&_UID=ohdemo&_PWD=Pass2010



if I had it like so:

.Stream(HttpWebRequest.Create(URL).GetResponse().GetResponseStream(), “Faktura.pdf”, “pdf”, “Faktura.pdf”, false)



I get the error:

“too many automatic redirections were attempted”



Or If I had it like so:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlpp);

request.Proxy = null;

request.UseDefaultCredentials = true;



CookieContainer cc = new CookieContainer();





request.CookieContainer = cc;



HttpWebResponse response = (HttpWebResponse)request.GetResponse();



.Stream(response.GetResponseStream(),filesave,“pdf”,filesave,false)



The viewer downloads the file but does not get pass the “Loading your content…” screen.









You can use the url above to test it.



Please let me know how to solve this issue.



Thanks.

Antonio

Hello Antonio,

We are sorry to hear that you have such issue. We were able reproduce it and now we are investigating this problem and will respond to you as soon as we will find a solution.

Thanks.

Hi Denis,



The issue seams to be with the latest version of the viewer.

I have been using the .Net 2.1.2 (Latest available to download) and it does not work.



Yesterday I realised that this version does not work in the way I am using it even when using the .Filepath method.



I only have a simple asp.net web form that receives a URL and then displays the file, so nothing to complicated there.



After many hours trying to get the viewer to work, I decided to try it with the version 2.1.0.



With this everything works, even the .stream method with the second option I have above.



Which means you had something in the previous version that you removed or it’s working in a different way.



Please have a look and let me know if you can replicate this too.



Antonio

Hello Antonio,

We are sorry to hear that you have such issue and we are sorry for long delay - the problem was not easy to solve. Here is how you can solve it:

1. Download and use the latest version of GroupDocs.Viewer ver. 2.2.5340.35377. I'll send a link to your corporate email.

2. Use the next code. This is sample code, so you need to replace some variables values (like filenames) and so on. It is 100% correct and should work. I used MVC with Razor layout, and placed all source code in the view, but you can place it inside the controller/code-behind, where you want.

@using Groupdocs.Web.UI
@{
ViewBag.Title = "Page";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@{

const String filename = “Faktura.pdf”;//or any other

String root_storage_path = Server.MapPath("~/testfiles/");//the same as in the Global.asax

String file_path = root_storage_path + “\” + filename;

if(File.Exists(file_path)==false)

{//some sort of caching

String urlpp = “http://www.infoportal4.com/demoserver/docs/~D1406?version=1000000&_UID=ohdemo&_PWD=Pass2010”;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlpp);

request.Proxy = null;

request.UseDefaultCredentials = true;

CookieContainer cc = new CookieContainer();

request.CookieContainer = cc;

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream stream = response.GetResponseStream();

using (FileStream fs = File.Create(file_path))

{

       stream.CopyTo(fs);</font></font><font size="3"><font face="Arial"><br></font></font><font size="3"><font face="Arial">        

}

}
}




@(Html.ViewerClientCode()

.TargetElementSelector("#test")

.FilePath(filename))

If you will have more questions please feel free to contact us.

It works now.



Thanks Denis.



Hi Denis,



I found a problem with it, using your method I’m unable to view the attachments of the following email:



https://www.infoportal4.com/demoserver/docs/~D6373?_UID=demo&_PWD=pass



Can you please have a look?



Thanks.

Antonio

Hello Antonio,

We are sorry to hear that you have this issue. We are able to reproduce this issue in old versions, it is already fixed in the GroupDocs.Viewer for .NET ver 2.3.0, where this mail message can be seen with all attachments in the both image-based and HTML-based rendering modes. I’ll send you a link to this new version of GroupDocs.Viewer via email.

Sorry for the inconvenience and please feel free to contact us if you will have other issues or questions.