ASP.Net Chart Control not displaying chart image - asp.net

I am working on a website built using VB.Net and ASP.Net (VS2019 .Net 4), and I am trying to add an ASP.Net Chart control, but i'm having lots of problems. My colleague has helped me with some of them, and now instead of just throwing an error it is generating the chart but isn't able to display it. I can see the image it has created on my machine, but if i right-click it on my page, and select 'Open image in new tab', i get this:
HTTP Error 500.21 - Internal Server Error Handler "ChartImg" has a bad
module "ManagedPipelineHandler" in its module list
Most likely causes: Managed handler is used; however, ASP.NET is not
installed or is not installed completely. There is a typographical
error in the configuration for the handler module list. During
application initialization, either the application initialization
feature has set skipManagedModules to true, or a rewrite rule is
setting a URL that maps to a managed handler and is also setting
SKIP_MANAGED_MODULES=1.
Things you can try: Install ASP.NET if you are using managed handler.
Ensure that the handler module's name is specified correctly. Module
names are case-sensitive and use the format
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule".
Ensure that any application initialization rewrite rules set
SKIP_MANAGED_MODULE=0 when setting a URL that maps to a managed
handler (such as .aspx, for example.) As an alternative, ensure that
application initialization rewrite rules map the request to an
unmanaged handler (for example, to an .htm file, which is mapped to
the StaticFileHandler.)
Detailed Error Information: Module IIS Web Core Notification
ExecuteRequestHandler Handler ChartImg Error Code 0x8007000d
Requested URL
http://localhost:80/WWW_TFS/GDNv1_Project/trunk-url/gDN/gDN_Support/ChartImg.axd?i=charts_0/chart_0_0.png&g=5850a0c2661a4402a1f0a33a33ec482a
Physical Path
C:\WWW\WWW_TFS\GDNv1_Project\gDN\gDN_Support\ChartImg.axd Logon
Method Anonymous Logon User Anonymous
After some more investigation with my colleague it looks like ChartImg.axd is missing. I've googled the issue but without any luck. Is there some kind of installation I need to do? Or can someone send me a copy of ChartImg.axd?
UPDATE: This issue is not fixed, but now i've started getting this error:
CSLLib.CSLException: Chart cannot save an item after 10 attempts.
---> System.IO.IOException: Chart cannot save an item after 10 attempts.
Everything i can see in Google suggests lack of disk space - but i have over 500GB of space left so that can't be the problem. Is there anything else that might cause this?
UPDATE: I have found that by changing the ChartImageHandler AppSetting to 'storage=memory;deleteAfterServicing=true;' the save issue goes away. The chart image is still not being displayed though.

Phew! Managed to solve this myself. I wasn't setting the control up correctly, so I made these changes and it worked:
Removed this from the asp.net page
<%# Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
Removed all web.config settings relating to asp.net chart
Removed the control from the page
Dragged the control on to the page in design view
Configure the chart control
Added a row to AppSettings in the web.config
key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"
Added a row to httpHandlers in web.config
path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"
Hope this helps others in the future

Related

When calling Web API in ASP.NET Web form, it could not load file or assembly 'Autofac.Integration.Web' or one of its dependencies

Maybe this question is too broad but it has wasted a lot of time and I can't find out a solution for that. So I decided to share my problem for any idea.
I have a ASP.NET Web Form project that has a web page (.aspx) including one tag like this:
<iframe runat="server" src="API URL"></iframe>
By running the project I get following error:
Could not load file or assembly 'Autofac.Integration.Web' or one of
its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load
file or assembly 'Autofac.Integration.Web' or one of its dependencies.
The system cannot find the file specified.
If I remove this tag, I don't have any error.
In fact, a couple of days before I added Autofac and it added following tags to my web config:
<modules runAllManagedModulesForAllRequests="true">
<add name="ContainerDisposal" type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web" preCondition="managedHandler"/>
<add name="PropertyInjection" type="Autofac.Integration.Web.Forms.PropertyInjectionModule, Autofac.Integration.Web" preCondition="managedHandler"/>
</modules>
When I am removing these add tags, I have no error. I don't know why these tags have negative impact on calling the API.
Another point, which it probably could be important, is API includes Hangfire. But as far as I know, there isn't any reference from Autofac in API.
Edit
The Web API is located in sub folder of Web form application in a operational server like this:
Web Form Application:
> bin
> web.config
> Web API
> bin
> web.config
As you can see, Web form application web.config affects on Web API because of location of the Web API. Due to some reasons, I can't change the locations.
I have seen many topics and articles about it, but they didn't give me a clue.
Any idea?
Thanks in advance.

Use local version of WebUIValidation.js in ASP.NET

In ASP.NET some scripts are fetched by default from ScriptResource.axd and WebResource.axd (These scrips are: MicrosoftAjaxTimer.js, MicrosoftAjax.js, MicrosoftAjaxWebForms.js in System.Web.Extensions, and DetailsView.js, Focus.js, GridView.js, Menu.js, SmartNav.js, TreeView.js, WebForms.js, WebParts.js and WebUIValidation.js)
For instance a script file called ScriptResource.axd?=someGuid.js will be loaded whenever a page with a validator is present.
How do I use my local WebUIValidation.js file instead? (in ASP.NET 4.5)
What I've tried:
I've read Scott Hanselman's old post on this. His idea is using a scriptmanager to override each script with a scriptreference to a local version like this
<asp:scriptreference name="WebForms.js" assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
http://www.hanselman.com/blog/ASPNETAjaxScriptCombiningAndMovingScriptResourceaxdsToStaticScripts.aspx
I've tried that, but it doesn't seem to work for WebUIValidation.js. As soon as a page with a validator is loaded, a ScriptResource.axd js file containing the validation script will always be fetched.
Hanselman did write a warning (this prior to the release of .NET 4) "NOTE: There're a few controls that don't use the ScriptManager, so they can't have their JavaScript suppressed. So far the Validators are the main culprits. I'm talking to the team and we'll see if we can't get that fixed in 4.0"
But I'm not sure what to do with that information, and I can't find any more recent updates on the subject.
I've also tried replacing the script by using one from my own CDN. I enabled cdn on my Scriptmanager
and in the Application_Start of global.asax I've tried setting a custom cdn path
ScriptManager.ScriptResourceMapping.AddDefinition("WebUIValidation", new
ScriptResourceDefinition
{
Path="~/Scripts/WebForms/WebUIValidation.js",
CdnPath = "https://dl.dropboxusercontent.com/u/4486136/WebUIValidation.js",
LoadSuccessExpression = "window.Sys",
CdnSupportsSecureConnection = true
});
This just results in 2 script instances being loaded, both from the dropbox AND the default cdn (ajax.aspnetcdn.com). The default cdn is loaded last though so it will be the only one executed.
So apparently, it doesnt recognize that I'm trying to overwrite.
I've also tried removing ScriptResource.axd completely, by adding the following to the in my Web.Config
<httpHandlers>
<remove verb="GET,HEAD" path="ScriptResource.axd" />
</httpHandlers>
That doesn't seem to do anything.

Physical Folder Breaks ASP.NET URL Routing on IIS Express

IIS Express is producing 403.14 Forbidden errors when a URL that would otherwise be handled through ASP.NET URL routing happens to correspond to a physical folder in my ASP.NET project. (The folder contains only code, and it's coincidental that the folder name happens to match the URL of a page; my URL structure is determined dynamically by a database, and users can edit that structure, so although I could just rename my project folder, in general I can't prevent this sort of collision occurring.)
This seems to be happening because the DirectoryListingModule steps in to handle the request, and then promptly fails it because directory browsing is disabled. I've tried removing this:
<system.webServer>
<handlers>
<remove name="StaticFile" />
<add name="StaticFile" path="*" verb="*"
modules="StaticFileModule" resourceType="Either" requireAccess="Read" />
</handlers>
</system.webServer>
That removes the default StaticFile handler configuration, which has modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule", and replaces it with a configuration that provides just the feature I want. (I want static file serving, but I have no need for directory listing or default documents in this app.) But the effect seems to be that IIS then produces a completely empty (0 byte) response (with a 200 status) when I hit the offending page.
So next, I tried configuring the StaticFile handler to handle only the specific physical folders that I want to make available:
<system.webServer>
<handlers>
<remove name="StaticFile" />
<add name="StaticFileCss" path="style/*.css" verb="*"
modules="StaticFileModule" resourceType="Either" requireAccess="Read" />
<add name="StaticFileScripts" path="Scripts/*" verb="*"
modules="StaticFileModule" resourceType="Either" requireAccess="Read" />
</handlers>
</system.webServer>
But when I hit the offending URL, this then produces a 404.4 - Not found error, with a message of The resource you are looking for does not have a handler associated with it.. (The Detailed Error Information on the error page says that we're in the IIS Web Core module, during the MapRequestHandler notification, the handler is Not yet determined, and there's an Error Code of 0x80070002, which is a COM HRESULT that corresponds to the Win32 ERROR_FILE_NOT_FOUND error.)
The mystifying thing is that it's not even bothering to ask ASP.NET whether it has a handler for it. IIS seems to be deciding all by itself that there definitely isn't a handler.
This only happens when there's a folder that matches the URL. All other resources with dynamically-determined URLs work just fine - IIS asks ASP.NET for a handler, ASP.NET's routing mechanism runs as normal, and if the URL corresponds to one of my dynamically defined pages, it all works fine. It's just the presence of a physical folder that stops this all from working.
I can see it's IIS doing this because I get one of the IIS-style error pages for this 404, and they have a distinctive design that's very different from the 404s produced by ASP.NET. (If I try to navigate to a URL that neither corresponds to a physical folder, nor to a dynamic resource, I get a 404 page generated by ASP.NET. So normally, IIS is definitely handing requests over to ASP.NET, but IIS is definitely getting in the way for these problematic resources.)
I tried adding this inside my <system.WebServer>, in case the problem was that IIS has decided that requests corresponding to physical folders do not meet the managedHandler precondition:
<modules runAllManagedModulesForAllRequests="true">
But that doesn't appear to help - it still doesn't get ASP.NET routing involved for URLs that correspond to physical folders. In any case, it would be suboptimal - I would prefer not to have managed handlers run for the content that I definitely want to handle as static content. I effectively want ASP.NET URL routing to be used as a backstop - I only want it to come into play if the URL definitely doesn't refer to static content.
I don't understand why ASP.NET isn't even asking ASP.NET what it thinks in this scenario. Why is it not calling into ASP.NET during the MapRequestHandler phase if there's a physical folder that happens to correspond to the URL?
When a physical file or folder with the same URL as the route is found, routes will not handle the request and the physical file will be served.
Althrough you can change this behavior by setting the RouteExistingFiles Property from the RouteCollection object to true.
Take a look at the MSDN page Scenarios when routing is not applied

ASPX page within a .aspx page with iframe throws 500.23 error

I'm trying to embed a ChartModule.aspx page within a Default.aspx page using an iframe.
The ChartModule has a button event which updates a chart. The ChartModule has its own ChartsModule.cs.
I'm getting this error:
HTTP Error 500.23 - Internal Server Error An ASP.NET setting has been
detected that does not apply in Integrated managed pipeline mode.Most
likely causes:
•This application defines configuration in the system.web/httpHandlers
section. Things you can try: •Migrate the configuration to the
system.webServer/handlers section. You can do so manually or by using
AppCmd from the command line. For example, from the IIS Express
install directory, run appcmd migrate config "Default Web Site/".
Using AppCmd to migrate your application will enable it to work in
Integrated mode. It will continue to work in Classic mode and on
previous versions of IIS. •If you are certain that it is OK to ignore
this error, it can be disabled by setting
system.webServer/validation#validateIntegratedModeConfiguration to
false. •Alternatively, switch the application to a Classic mode
application pool. For example, from the IIS Express install directory,
run appcmd set app "Default Web Site/"
/applicationPool:"Clr4ClassicAppPool". Only do this if you are unable
to migrate your application.
Detailed Error Information: Module ConfigurationValidationModule
Notification BeginRequest Handler
PageHandlerFactory-Integrated-4.0 Error Code 0x80070032 Requested
URL http://localhost:4161/Default.aspx Physical Path
C:\Documents and
Settings\singhm\Desktop\Temp\Trial2\Trial2\Default.aspx Logon Method
Not yet determined Logon User Not yet determined Request Tracing
Directory
Why is this?
While this may not answer your question directly, here is a thought:
If you have the option, consider turning ChartModule.aspx into a UserControl (ascx), which acts just like another "page" (same lifecycle, its own codebehind file, etc) but integrates more cleanly into an existing aspx page. The above link should be a good introduction to creating and using UserControls.
The error message contains a clue to the solution:
setting system.webServer/validation#validateIntegratedModeConfiguration to false
So make sure the following is present in your web.config:
<validation validateIntegratedModeConfiguration="false"/>
For example:
<configuration>
<!-- your existing settings -->
<system.webServer>
<!-- Add this to here.... -->
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
IIS 7 and ASP.NET are quite helpful these days with regard to to error messages and hints contained therein so you should take the time to read them.
I would really recommend using a usercontrol page instead of iframes in asp.net this way you can bind that usercontrol by doing
public override DataBind()
in that you can pass anything into that usercontrol page like refresh data, load certain data, etc..

Why isn't my IHttpHandler being called?

I'm trying to get a custom handler to work for a specific URL (or set of URLs) in ASP.NET 3.5.
The handler doesn't actually do anything significant yet - it just logs the request. I can post the code if anyone things it's relevant, but I really don't think it's being called at all. (In particular, for normal exceptions I get a custom error page and logging... here I'm just getting the vanilla IIS 404.)
Here's the relevant bit of the web.config file:
<system.web>
<httpHandlers>
<add verb="GET,POST" path="*.robot" validate="false"
type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</httpHandlers>
</system.web>
(Obviously there's other stuff in that section too, but I don't think it's relevant.)
Locally, running under the dev server, it works fine. On my real box, I always get a 404. Everything under the web site directory itself is the same (replicated via svn). That includes the bin directory containing CSharpInDepth.dll, which I've verified contains CSharpInDepth.Wave.RobotHandler.
I try to fetch http://csharpindepth.com/foo.robot and just get a 404.
I've tried with and without the assembly name, specific URLs or wildcarded ones... nothing's working.
I'm sure I've just missed some simple flag somewhere in the IIS configuration, but I'm blowed if I can find it...
EDIT: It's IIS version 6. Attempting to add *.robot to the ISAPI filter now...
Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:
<system.webmodules>
....
<modules>
<add name="RobotHandler" type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</modules>
....
</system.webmodules>
If it's IIS6 then you'll need to map *.robots to the ASP.NET ISAPI DLL.
(For the non-Skeets you do this as follows)
Open up IIS admin.
Right click on
the Web site you want to configure
and select Properties form the
context menu. This will display the
Web Site Properties dialog.
Select
the Home Directory tab and click the
Configuration button. This will
display the Application
Configuration dialog box.
Click
Add.
Select the aspnet_isapi.dll
from the .NET framework directory,
the extension you want mapped and
either All Verbs, or just the ones
you want to map.
Click ok.
Jon,
You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.

Resources