locked
MS Chart not working (Unknown server tag 'asp:Chart') RRS feed

  • Question

  • User22075012 posted

    I'm trying to use MS Chart for the first time and it is not working. I'm getting the following error message:

    Unknown server tag 'asp:Chart'.

    Here's what I've tried.

    1. I downloaded and installed mschart.exe.
    2. I then tried altering my web.config file in various ways based on the other threads and outher sources I found, but none of these worked for me including (and others similar):

    http://www.aspnettutorials.com/tutorials/charts/ms-chart-controls-install/

    This made the "Uknown server tag" error go a way, but then I got a new error message stating (related to the suggested tags added from the above article):

    "Unrecognized attribute 'path'. Note that attribute ..."

    Questions:

    1. If I have ASP.NET 4.5 installed, why would I have any problems at all or even have to install mschart.exe? I thought MS Chart came with automatically. Is there a seeting I have to change, or do I have to (stupid question) turn on or apply 4.5 somehow vs. just installing it?

    2. If the answer to #1 is it's not automatica and I do have to change something, what do I have to change?

    Your time, effort, and help are greatly appreciated! Thanks in advance.

    By the way...

    I have ASP.NET 4.5 installed, Windows 8.1, IIS Manger 8.5, and do my development in Expression Web.

    Sunday, April 6, 2014 3:19 AM

Answers

  • User22075012 posted

    Ok. So my problem is now resolved. Before I finished reformatting and configuring my computer, I came across some additional resources and decided to try them out and they worked.  Here's what worked for me:

    For those interested, first On the webpage that I wanted to actually display my chart I added a "Register" declaration at the top (directly) of my page (line below my page declaration to my code-behind page.  A basic version of my page now looks like this:

    <%@ Page Language="vb" Debug="true" CodeFile="myChartPage.vb" Inherits="myChartPageCode" %>
    <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
    
    <html>
    <head><title>My Chart Example</title></head>
    <body>
    <form runat="server" id="From1" method="post" encType="multipart/form-data">
    <asp:Chart id="Chart1" runat="server" DataSourceID="Chart1DataSource" Height="200px" Width="535px">
      <series>
        <asp:Series ChartType="Pie" Name="Series1" XValueMember="XVAL" YvalueMembers="YVAL"></asp:Series>
      </series>
      <chartareas>
        <asp:ChartArea Name="ChartArea1"></asp:ChartArea>
      </chartareas>
    </asp:Chart>
    <asp:AccessDataSource runat="server" ID="Chart1DataSource" DataFile="<%$ AppSettings:myDbConnString %>"
    SelectCommand="SELECT friendstate AS XVAL, Count(friendid) AS YVAL_COUNT FROM myfriendstable GROUP BY friendstate;">
    </asp:AccessDataSource>
    </form>
    </body>
    </html>
    

    Then, in my web.config file I "only" added the following. Emphasis on "only" because when I add other items that were suggested by others, for some reason it didn't work (later I'll try added the things I left out one-by-one to see what actually is causing it to break, but for now it works):

    <configuration>
       <appSettings>
          <add key="ChartImageHandler" value="storage=memory;timeout=30;" />
       </appSettings>
       <system.webServer>
          <handlers>
             <add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </handlers>
       </system.webServer>
       <system.web>
          <!-- Did not add anything here //-->
       </system.web>
    </configuration>

    That's it.

    After adding those three things it worked:

    1) Added a "Register" declaration to the page itself
    2) Added a appSettings "key" to the webconfig file.
    3) Added a system.webServer "hander" to the webconfig fle.

    It worked both on my local development server and when I loaded it to my godaddy hosted site.

    Couple things to note for those who may have similar problem:

    1) I confirmed I'm using ASP.NET v4.0 on my local and godaddy account and IIS 8.5/IIS 8.0 respectively on both.
    2) Some resources suggest specifying a path for the "ChartImageHandler" key I added to my config file in the "value" argument (this specifies where the chart image is saved - I think), and then, make sure that path is unprotected. That didn't work for me. When I took it out and left it as you see above, then it worked.
    3) The order of your sections in your config file don't seem to matter.
    4) Some resources also suggested you need to add a reference to your code behind page (e.g. in your page declaration section add a "Imports...." for the chart library object. I didn't have to do that to get mine to work. But, I assume I may/would if I plan to try to to programmatically control/change my chart.

    Whew!

    Anwyay, I hope that helps someone else who had similar problems. And, thanks everyone for your input and help!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2014 5:51 PM

All replies

  • User-902516579 posted

    Hi,

    I created a tutorial here, maybe it will help.

    http://www.thebestcsharpprogrammerintheworld.com/blogs/how-to-create-a-pie-chart-using-aspnet-and-c-sharp.aspx

    HTH, Benjamin

    Monday, April 7, 2014 6:23 AM
  • User-1034726716 posted

    Charts should be included already in .NET 4 and higher though I'm not exactly sure if that's included in the express or expression web version.

    Monday, April 7, 2014 1:45 PM
  • User22075012 posted

    Thanks for your response. But this is not working for me. Based on your tutorial, I added the following to my web.config file (I assumed which sections to put it in, since your article didn't specific):

    <configuration>
        <system.web>
             <customErrors mode="Off" />
             <identity impersonate="false" />
             <httpHandlers>
                     <add 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"/>
             </httpHandlers>
    
             <pages>
                     <controls>
                             <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                     </controls>
             </pages>
        </system.web>
    
        <appSettings>
             'Nothing added here
        </appSettings>
    
        <system.webServer>
             'Nothing added here
        </system.webServer>
    </configuration>

    Witht he above I get the error:

    HTTP Error 500.23 - Internal Server Error. An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

    I did some digging and used a recommendation from anoter source to add the following to the system.webServer section and altered as such (some suggested changing the mode from "itntergrated" to "classic" in IIS, but I wasn't sure how that would impact other sites I have on this computer, so I elected to follow this method instead. Plus, I admittedly don't know much about what this all means... just I'm just following orders so-to-speak =)):

        <system.webServer>
            <validation validateIntegratedModeConfiguration="false" />
        </system.webServer>

    After including that, I now get the following error:

    No http handler was found for request type 'GET'

    I looked up that error message and still don't have a solution as of yet.

    Arrgh! Frustrating... I'm still not even sure why I need to add anything or change any settings if Chart is already included in my version of ASP.NET.  For example, I don't do anything to use the GridView control, it just works because it's already included in ASP.NET. 

    Thanks again for your help.

    Tuesday, April 8, 2014 12:03 AM
  • User22075012 posted

    Should I not have installed MSCharte.exe again? Could that have caused a problem?

    The tool is not available in MS expression web, but the application you use to desgin your pages should not matter when it comes to making the chart tool work or not.  I'm just manually typing in the html/asp.net text in my page. It should work.

    Tuesday, April 8, 2014 12:05 AM
  • User724169276 posted

    Hello,

    Revert back what changes you made in web.config to normal.yes chart control should be there by default.Just make sure you have referenced the chart dll in your solution.

    Chart DLLs are installed in this folder “%Program File%\Microsoft Chart Controls\Assemblies”. You can just drag-and-drop chart DLL in the VS Toolbox. You can also right click on the toolbox and browse the DLLs you want to add. Make sure you add control DLL in the Design-time DLL.

    OR

    Right clicked on the toolbox -> choose item -> .net framework components -> browse -> locate the System.Web.DataVisualization.dll and click ok.

    Tuesday, April 8, 2014 12:08 AM
  • User22075012 posted

    I'm not using Visual Studio. I'm using Expression Web.  How can I make this work with Expression Web?

    I do have an VS 2008, but did not install it on this machine as it's been a while since I've used VS and just want for the low hanging fruit application and what was already installed on the machine. Maybe I should, but will that work in VS 2008 as well?

    Tuesday, April 8, 2014 1:58 AM
  • User724169276 posted

    but will that work in VS 2008 as well?

    yes vs2008 supports chart control.

    Tuesday, April 8, 2014 2:09 AM
  • User22075012 posted

    Ok. I take back what I said. =) I do have VS 2008 installed on this machine. Just haven't used it. It's been a while =) I'll try what you suggested. But, real quick... something very weird??  When I opened my "Default Website" in VS 2008, it gives me a message stating:

    "The Web site 'http://localhost/' is configured to run on the .NET Framework version 2.0. Do you want to upgrade the Web site to use the .NET Framework version 3.5?"

    What's weird about this is that I have .NET 4.5 on the machine and when I look at my "Default Website" in IIS 8.5 Manager, it says the "Default Website" (which is localhost) is assigened to the "DefaultAppPool" which is using .NET CLR Verison v4.0.  Wouldn't that make it configured under v4.0.

    I'm clearly not understanding something here.

    Tuesday, April 8, 2014 2:36 AM
  • User724169276 posted

    ptownbro

    The Web site 'http://localhost/' is configured to run on the .NET Framework version 2.0. Do you want to upgrade the Web site to use the .NET Framework version 3.5?

    it means that, when you created the project the framework was 2.0 and now VS is suggesting you to open the page in  3.5 version to run properly.

    ptownbro

    What's weird about this is that I have .NET 4.5 on the machine and when I look at my "Default Website" in IIS 8.5 Manager, it says the "Default Website" (which is localhost) is assigened to the "DefaultAppPool" which is using .NET CLR Verison v4.0.  Wouldn't that make it configured under v4.0.

    this wont be a problem.clr version and .net framework version are different things dont relate them.CLR v2.0.50727 is shared by .NET 2.0/3.0/3.5, while CLR v4.0.30319 is shared by .NET 4.0 and 4.5. I hope this clears the picture.

    Tuesday, April 8, 2014 2:49 AM
  • User22075012 posted

    Ok. Thanks. Then, maybe that's what my real problem is?  Although this whole time I've been assuming I'm operating under the .NET 4.5 framework (because of what I saw in IIS) I'm really been using 2.0 which is why MS Chart is not working automatically.  Is that the problem?

    Tuesday, April 8, 2014 12:18 PM
  • User724169276 posted

    yes .. may be .. sometimes when you upgrade your framework you may have to reference the dll also ..like i explained in few post before.

    Tuesday, April 8, 2014 12:43 PM
  • User22075012 posted

    Ok. I've tried for several days now in a few different ways to do go the Visual Studio route. Unfortunately that is not an option for me.  I spent time downloading and installing VS2013. While that application does have MS Chart and it will work on VS internal webserver, I need it to work on the localhost server (or whatever you call it).  Also, I cannot convert the current website as it's written/developed to VS. It's written using asp and old asp.net mindset and would need to be completely redone to work in VS (I tired just bringint it over and ran into a whole host of problems, each time I'd fix one another would come up until I had to give up).

    So. I'm back to where I started. How can I get MS Chart to work? Anyone?

    I'm using Expression Web, Windows 8.1, IIS 8.5, and ... I think ASP.NET 4.0.

    It seems that my problem may be that I'm not on the ASP.NET version I thin I am. So any help on how to set that up properly on my localhost using IIS 8.5 would be helpful.

    In the meantime, I'm going to try to reconfigure this machine from scratch (reformatt, reinstall, ... the works) to see if that helps in case it's a configuration problem.

    Thanks everyone for your help!

    Friday, April 11, 2014 7:45 PM
  • User22075012 posted

    Ok. So my problem is now resolved. Before I finished reformatting and configuring my computer, I came across some additional resources and decided to try them out and they worked.  Here's what worked for me:

    For those interested, first On the webpage that I wanted to actually display my chart I added a "Register" declaration at the top (directly) of my page (line below my page declaration to my code-behind page.  A basic version of my page now looks like this:

    <%@ Page Language="vb" Debug="true" CodeFile="myChartPage.vb" Inherits="myChartPageCode" %>
    <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
    
    <html>
    <head><title>My Chart Example</title></head>
    <body>
    <form runat="server" id="From1" method="post" encType="multipart/form-data">
    <asp:Chart id="Chart1" runat="server" DataSourceID="Chart1DataSource" Height="200px" Width="535px">
      <series>
        <asp:Series ChartType="Pie" Name="Series1" XValueMember="XVAL" YvalueMembers="YVAL"></asp:Series>
      </series>
      <chartareas>
        <asp:ChartArea Name="ChartArea1"></asp:ChartArea>
      </chartareas>
    </asp:Chart>
    <asp:AccessDataSource runat="server" ID="Chart1DataSource" DataFile="<%$ AppSettings:myDbConnString %>"
    SelectCommand="SELECT friendstate AS XVAL, Count(friendid) AS YVAL_COUNT FROM myfriendstable GROUP BY friendstate;">
    </asp:AccessDataSource>
    </form>
    </body>
    </html>
    

    Then, in my web.config file I "only" added the following. Emphasis on "only" because when I add other items that were suggested by others, for some reason it didn't work (later I'll try added the things I left out one-by-one to see what actually is causing it to break, but for now it works):

    <configuration>
       <appSettings>
          <add key="ChartImageHandler" value="storage=memory;timeout=30;" />
       </appSettings>
       <system.webServer>
          <handlers>
             <add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </handlers>
       </system.webServer>
       <system.web>
          <!-- Did not add anything here //-->
       </system.web>
    </configuration>

    That's it.

    After adding those three things it worked:

    1) Added a "Register" declaration to the page itself
    2) Added a appSettings "key" to the webconfig file.
    3) Added a system.webServer "hander" to the webconfig fle.

    It worked both on my local development server and when I loaded it to my godaddy hosted site.

    Couple things to note for those who may have similar problem:

    1) I confirmed I'm using ASP.NET v4.0 on my local and godaddy account and IIS 8.5/IIS 8.0 respectively on both.
    2) Some resources suggest specifying a path for the "ChartImageHandler" key I added to my config file in the "value" argument (this specifies where the chart image is saved - I think), and then, make sure that path is unprotected. That didn't work for me. When I took it out and left it as you see above, then it worked.
    3) The order of your sections in your config file don't seem to matter.
    4) Some resources also suggested you need to add a reference to your code behind page (e.g. in your page declaration section add a "Imports...." for the chart library object. I didn't have to do that to get mine to work. But, I assume I may/would if I plan to try to to programmatically control/change my chart.

    Whew!

    Anwyay, I hope that helps someone else who had similar problems. And, thanks everyone for your input and help!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 14, 2014 5:51 PM