Scott Buchanan
Top achievements
Rank 1
Scott Buchanan
asked on 06 Aug 2011, 10:30 PM
We have a ReportViewerExtension that casts an instance of Telerik.ReportViewer.WebForms.HttpHandler as IHttpHandler. This has worked for years, but no longer runs after installing Q2 2011, throwing a run-time error that "Unable to cast object of type 'Telerik.ReportViewer.WebForms.HttpHandler' to type 'System.Web.IHttpHandler'."
Any ideas what happened (and how to resolve)?
Best,
Scott
Any ideas what happened (and how to resolve)?
Best,
Scott
4 Answers, 1 is accepted
0
Hi Scott,
For the Q2 2011 release we reworked some parts of the ASP.NET report viewer in order to enhance its performance in out-proc Session state mode. As a result the HttpHandler class now implements the IHttpHandlerFactory interface instead of IHttpHandler. In order to make it work as in the previous versions you have to change the cast and make the necessary modifications that result from it (should be a couple of lines). Please, let us know if you experience any problems in doing this so that we can help.
In general, the http handler is for internal use by the viewer and should not be called from outside. We will appreciate if you can elaborate on your exact scenario which requires to use the handler manually. Thank you in advance.
Regards,
Chavdar
the Telerik team
For the Q2 2011 release we reworked some parts of the ASP.NET report viewer in order to enhance its performance in out-proc Session state mode. As a result the HttpHandler class now implements the IHttpHandlerFactory interface instead of IHttpHandler. In order to make it work as in the previous versions you have to change the cast and make the necessary modifications that result from it (should be a couple of lines). Please, let us know if you experience any problems in doing this so that we can help.
In general, the http handler is for internal use by the viewer and should not be called from outside. We will appreciate if you can elaborate on your exact scenario which requires to use the handler manually. Thank you in advance.
Regards,
Chavdar
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Scott Buchanan
Top achievements
Rank 1
answered on 08 Aug 2011, 01:39 PM
We test and handle two conditions on ProcessRequest()
1. If the session has expired we redirect to the parent page (which then redirects to the login page). Otherwise, the user was shown a report that said "Report is unavailable or session has expired.", which confused our test users (they did not know how to get back to a login page).
2. According to the check in notes, the following code (executes for XLS exports) allows users of Macs with Office 2004(?) to open the Excel export files:
Best,
Scott
1. If the session has expired we redirect to the parent page (which then redirects to the login page). Otherwise, the user was shown a report that said "Report is unavailable or session has expired.", which confused our test users (they did not know how to get back to a login page).
2. According to the check in notes, the following code (executes for XLS exports) allows users of Macs with Office 2004(?) to open the Excel export files:
string fname = Path.GetTempFileName();
FileStream fs = File.Open(fname, FileMode.OpenOrCreate);
try
{
ms.WriteTo(fs);
ms.Flush();
}
finally
{
fs.Close();
}
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fname + ";Persist Security Info=False;Extended Properties=\"Excel 8.0;HDR=NO\"");
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM [sheet1$A1:A1]";
object o = cmd.ExecuteScalar();
cmd.CommandText = "UPDATE [Sheet1$A1:A1] SET F1=?";
cmd.Parameters.AddWithValue("@F1", o);
cmd.ExecuteNonQuery();
con.Close();
fs = File.Open(fname, FileMode.Open);
MemoryStream ms2;
try
{
ms2 = new MemoryStream((int)fs.Length);
ms2.SetLength(fs.Length);
fs.Read(ms2.GetBuffer(), 0, (int)fs.Length);
}
finally
{
fs.Close();
}
File.Delete(fname);
ms2.Position = 0;
ms = ms2;
Best,
Scott
0
Scott Buchanan
Top achievements
Rank 1
answered on 09 Aug 2011, 03:15 AM
I did not have any real success refactoring to use IHttphandlerFactory. I expected to have to use GetHandler(), but did not seem that I had access to the necessary parameters...
Some hints about those "couple of lines" would be appreciated.
Currently, I modified web.config to exclude our extension - very pleased with the performance and DOCX/XLSX exports. Thanks!
Scott
Some hints about those "couple of lines" would be appreciated.
Currently, I modified web.config to exclude our extension - very pleased with the performance and DOCX/XLSX exports. Thanks!
Scott
0
Hello Scott,
The correct solution depends on your actual ReportViewerExtension implementation so without knowing it it will be hard to give any proper guidance. If the problem is only with the arguments that the GetHandler method receives then you can pass an empty string for the requestType, url and pathTranslated parameters. Still, we will appreciate if you could open a support ticket and send us the relevant code to let us know how exactly the factory/handler are used in order to avoid any guesses and make concrete suggestions.
All the best,
Chavdar
the Telerik team
The correct solution depends on your actual ReportViewerExtension implementation so without knowing it it will be hard to give any proper guidance. If the problem is only with the arguments that the GetHandler method receives then you can pass an empty string for the requestType, url and pathTranslated parameters. Still, we will appreciate if you could open a support ticket and send us the relevant code to let us know how exactly the factory/handler are used in order to avoid any guesses and make concrete suggestions.
All the best,
Chavdar
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>