Telerik Report Viewer messed up - c#

Telerik Report messed up like this
Tried this fix that the article suggests but in vain..ie added "preCondition" attribute but we.config says preCondition="integratedMode" Attribute is not declared"..Where do I need to declare it and how!??
I added xmlns value like this in web.config after reading a forum:-
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
It still is giving this error:-
Unrecognized attribute 'preCondition'. Note that attribute names are case-sensitive.
[EDIT]
ok that fix is for IIS7..didn't notice..mine is IIS 5..so how do I fix the appearance of Telerik Report Viewer now??

Just in case, verify that you have the right "Version=xxxxx" on the web.config reference to the Telerik.ReportViewer.axd.
I've seen sometimes the report viewer messed up becasue the web.config was referencing an older version.
sample:
....
....
<add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=5.1.11.928, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode,runtimeVersionv2.0" />
</handlers>
...
...
<add verb="*" path="Telerik.ReportViewer.axd" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=5.1.11.928, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" validate="true" />
</httpHandlers>

Related

Crystal report not showing images : CrytalImageHandler not found

I believe I have come across what I consider my most difficult task to do using crystal reports.
Problem
I am attempting to show to images on my report, one a varbinary stored in the database, and the second, a logo added from my desktop.The problem I am being faced with is, CrystalImageHandler not found and nothing I have tried works.
And the following errors are thrown
http://localhost:1979/ASP/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_9b453c74-dbe2-4f03-832e-b1bd43e6ec43.png 404 (Not Found)
http://localhost:1979/ASP/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_0bf1fda9-3e87-446d-94a4-aaad9aa7e53d.png 404 (Not Found)
What I have tried
I have attempted to ignore the routes. However, if I try to navigate to the image by removing the 'ASP' path where my aspx is, it still doesn't work. However, this is my RouteConfig.cs where the 'ASP' doesn't seem to be ignored
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{*allaspx}", new { allaspx = #".*(CrystalImageHandler).*" });
routes.IgnoreRoute("ASP/{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("ASP/{resource}.aspx/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
I have also attempted to add it to the handler tag in the web.config file.
I have tried adding
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web,Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
</httpHandlers>
to the main web.config however, on launching my application I get the error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. it then says I can ignore the error If you are certain that it is OK to ignore this error, it can be disabled by setting system.webServer/validation#validateIntegratedModeConfiguration to false. But setting that to false does not work.
I place it in the second web.config file(the one in views folder., but that does not fix the issue of no picture being displayed.
I would greatly appreciate it if I am offered assistance or a bit of guidance to solve this issue. Cause it seems odd that something so simple could be this challenging.
I also faced this issue regarding loading images on crystal report in mvc but able to solve this issue by following these steps.
Possible Solutions:
The first thing to check is whether the Crystal Reports Image Handler has been included. This handler configuration doesn't seem to be added to the web.config by default, so open it up & look at the <httpHandlers> element. You need the following there:
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
Also, check the <handlers> element in the <system.webServer> parent node, as the handler needs to be added there as well:
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
Issue in ASP.NET MVC
If you are using Crystal Reports in ASP.NET MVC, the images may still fail to load. This is because the ASP.NET MVC routing engine is trying to map the resource request for the Image Handler to a controller action & since it can't, returns a 404 status.
To resolve this tell ASP.NET MVC routing engine to ignore requests for this resource. To do so, open up your routing configuration code (RouteConfig.cs).
There should already be an ignore for .axd resources. Add the following ignore rule:
routes.IgnoreRoute("{*allaspx}", new { allaspx = #".*(CrystalImageHandler).*" });
Source
I faced a similar issue. I found success in altering the path within the code shown below from Web.config. I replaced CrystalImageHandler.aspx with CrystalImageHandler*. This seems to have resolved my issue. I don't really understand why to be honest. I came someone's post online who suggested that he could'nt find the CrsytalImageHandler.aspx page and decided to point only to CrystalImageHandler. I thought this might be worth a try for some.
I was using VS2015, .Net 4.5, C#
<httpHandlers>
<add verb="GET" path="CrystalImageHandler*" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler*" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
</handlers>
Hope this helps,
Mark
Add to RegisterRoutes
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
then fix CrystalImageHandler in Web.config
check web.config under <system.web> contains
(replace with crystal version)
<httpHandlers>
<add verb="GET" path="CrystalImageHandler*" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
</httpHandlers>
and under <system.webServer> contains
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler*" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
</handlers>
Replace All
path="CrystalImageHandler.aspx"
with
path="CrystalImageHandler*"
After add necessary change in web.config. if still not work then you can try this
For ASP.NET MVC Project
in route config
add followoing line
routes.IgnoreRoute("Reports/Viewer/{resource}.aspx/{*pathInfo}");
you may need to change the path according to aspx page location

HttpHandler being overlooked in favor of route

I have built a custom HttpHandler that issues a status page whenever a specific resource is requested by the load balancer.
Some more background: It can't be a controller as I need to be able to share it with other assemblies and the company coding policy is not to allow controllers from other assemblies.
Also, I cannot use a delegating handler as I don't want to affect the pipeline by adding a global message handler.
So I have the following in the web.config:
<system.web>
...
<httpHandlers>
<!-- Status Page-->
<add verb="GET" path="*" type="Web.Api.Framework.StatusPageHandler, Web.Api.Framework" />
</httpHandlers>
...
</system.web>
<system.webServer>
...
<handlers>
<clear/>
<add name="StatusPageHandler" path="*" verb="GET" type="Web.Api.Framework.StatusPageHandler, Web.Api.Framework" />
</handlers>
...
</system.webServer>
When I try to access the handler (http://foo.bar/status) it fails with a 404. If I remove the resource mapping for the default controller (from global.asax) then it works. i.e. without the following statement in global.asax it works:
routes.MapRoute("Default", "{controller}", null, null);
I stumbled upon a url for which it does work: http://foo.bar/status/XXX, but that is hardly ideal - we don't want to have to extend the url in that "ugly" way.
How do I get it to work?
One way to get it to work. Change Web.Config like so.
<add name="StatusPageHandler" path="status" verb="GET"
type="Web.Api.Framework.StatusPageHandler, Web.Api.Framework" />
Add the line in Global.asax (RouteConfig.cs?) to ignore this route. Make sure you add this line before routes.MapRoute.
routes.IgnoreRoute("status");

Monorail RC 2.1 routing thinks that a missing static file (like a .jpg) is an controller/action

I've started learning (and using) Monorail a little while ago, and recently, I've dabbled into routing. Unfortunately, the documentation around it is kinda sparse, but I've managed to get some info from various blog posts, most of them 2 years + old. I managed to setup the routing pretty quickly, BUT I realized that Monorail's routing engine confuses .jpeg files as controller/action requests WHEN they are not found.
The webconfig file is pretty standard:
<monorail useWindsorIntegration="false" defaultUrlExtension=".rails">
<url useExtensions="true"/>
<controllers>
<assembly>NetTwitter.Web</assembly>
</controllers>
<viewcomponents>
<assembly>NetTwitter.Web</assembly>
</viewcomponents>
<viewEngine viewPathRoot="Views" customEngine="Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine, Castle.MonoRail.Framework.Views.NVelocity"/>
</monorail>
<system.web>
<httpHandlers>
<!-- block direct user access to template files -->
<add verb="*" path="*.vm" type="System.Web.HttpForbiddenHandler"/>
<add verb="*" path="*.boo" type="System.Web.HttpForbiddenHandler"/>
<add verb="*" path="*.st" type="System.Web.HttpForbiddenHandler"/>
<add verb="GET" path="*.css" type="System.Web.StaticFileHandler" />
<add verb="GET" path="*.js" type="System.Web.StaticFileHandler" />
<add verb="GET" path="*.jpg" type="System.Web.StaticFileHandler" />
<add verb="GET" path="*.gif" type="System.Web.StaticFileHandler" />
<add verb="GET" path="*.png" type="System.Web.StaticFileHandler" />
<add verb="GET" path="*.jpeg" type="System.Web.StaticFileHandler" />
<add verb="*" path="*.rails" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework"/>
</httpHandlers>
<httpModules>
<add name="routing" type="Castle.MonoRail.Framework.Routing.RoutingModuleEx, Castle.MonoRail.Framework" />
</httpModules>
As is the initialization of the routing engine inside the Global.asax:
public void Application_OnStart()
{
log4net.Config.XmlConfigurator.Configure();
RoutingModuleEx.Engine.Add(
new PatternRoute("<controller>/[action]"));
}
The error itself says it pretty clearly:
{"Controller not found. Area: '' Controller Name: 'content'"}
So, what can I do? Thanks in advance.
This is because you are using the RoutingModuleEx. That will rewrite the URL before the actual httpHandlers are matched against.
And your route is to general for this, probably.
We solve it by having a /static/ folder which has it's own web.config, therefore overriding the original web.config.
This one contians only:
<system.webServer>
<handlers>
<clear/>
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="Either" requireAccess="Read" />
</handlers>
</system.webServer>
You might want to remove the rounting module from here as well, since it might be inherited. We have however not noticed any issue with it, but haven't really put my head in it either. It might be that we don't match any routes when we are one level down, or subfolders doesn't inherit httpModules.

Register HttpHandler under a path/folder

Why cant i register a HttpModule under a directory?
<system.web>
<httpHandlers>
<add verb="*" path="/home/facebookredirect.axd" type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" />
</httpHandlers>
</system.web>
<handlers>
<add name="facebookredirect.axd" verb="*" path="/home/facebookredirect.axd" type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" />
</handlers>
when the request comes to /home/facebookredirect.axd i m getting a 404. why this is not working?
I want the facebookredirect.axd to work under /home/
Below is frm, global.asx
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Essentially. home doesnt exist, there is a home controller. But i want to use this path.
path="/home/facebookredirect.axd"
should be:
path="home/facebookredirect.axd"
Also you need to exclude this url from your routes:
routes.IgnoreRoute("home/{resource}.axd");
It's probably because there is a generic .axd handler (i.e. *.axd) added before yours.
If you remove this before adding your handlers, then add it back in after your handler is added, it could resolve the problem (disclaimer: haven't tried it, just going on the evidence).
Try to add resourceType="Unspecified"
so it becames
<add name="facebookredirect.axd" verb="*" path="/home/facebookredirect.axd"
type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web"
resourceType="Unspecified" />
At least, i have handlers working with folders with the same declaration.
Also folder "Home" should exists on server

How do I exclude things that match the specified path for an HttpHandler in ASP.Net?

I know that if I want to have requests for MyPage.aspx go to the class called MyHandler in the assembly called MyAssembly, I can add this to my web.config file:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="MyPage.aspx" type="MyHandler, MyAssembly"/>
</system.web>
</configuration>
This works for any MyPage.aspx at the (made up) URL: www.mycoolsite.com/MyProject/[SomePathHere]/MyPage.aspx
What if I want to do it for every MyPage.aspx except www.mycoolsite.com/MyProject/NoHandler/MyPage.aspx
Is there a way to exclude that path from the handler?
You can put a web.config in the NoHandler folder that defines a different handler (NotFound if you want to server a 404 style, etc). Same format as your current web.config, just put only the elements you want to override like the handler.
Here's an example if you want to override with a 404 in that directory:
<configuration>
<system.web>
<httpHandlers>
<remove verb="*" path="MyPage.aspx" type="MyHandler, MyAssembly"/>
<add verb="*" path="MyPage.aspx" type="MySpecialHandler, MyAssembly"/>
</httpHandlers>
</system.web>
</configuration>

Categories