Asp.Net: Caching Rss feeds

For dotNetSearch.net I needed to cache the RSS feed (on the right). I did this with the .Net Cache namespace.


if(Cache.Get(RssUrl) == null)
{
 RssDocument rssFeed = RssDocument.Load(new Uri(RssUrl));
 Cache.Insert(RssUrl, XDocument.Parse(rssFeed.ToXml(DocumentType.Rss)), null, DateTime.Now.AddMinutes(15), TimeSpan.Zero);
}

XDocument rssXml = (XDocument)Cache.Get(RssUrl);


In this examle I add the RSSFeed content as object in the cache and use the url of the RSS feed as Key. The Cache will expire (and cleared) after 15 minutes.

SQLReporting service: Deployment

When deploying a project to a internal test server I got the following error:

The definition of the report ‘Main Report’ is invalid.
An unexpected error occurred in Report Processing.
Could not load file or assembly ‘Microsoft.ReportViewer.ProcessingObjectModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.
 

Fix this by adding a reference to ProcessingObjecdtModel.dll in you project. You can find the ProcessingObjecdtModel.dll in the GAC. The problem with the GAC is that you can’t copy the .dll from the GAC using Windows Explorer. But you can copy the DLL with Command Prompt (cmd.exe).

To do this:

    1. Run -> cmd.exe
    2. cd C:WindowsassemblyGAC_MSILMicrosoft.ReportViewer.ProcessingObjectModel 9.0.0.0__b03f5f7f11d50a3a
    3. copy Microsoft.ReportViewer.ProcessingObjectModel.dll c:locationFolder
  • This action will look like this:

     

    Copy the Microsoft.ReportViewer.ProcessingObjectModel.dll to your Bin folder or at a reference to the assembly.

    Hope it helps,

    Pieter

    Asp.Net: Charting Control (Error ChartImg.axd)

    After installing and playing with the Asp.Net Charting control I decided to use it for a customer. When integrating the control to the project I got the following error

    "Error executing child request for ChartImg.axd"

    This error occurred because I did not update my web.config file. You have to add the following appSettingkey, httpHandler and handler.

    [code:xml]

    <appSettings>
        <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:TempImageFilesDit;" />
    </appSettings>
    <httpHandlers>
        <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
    </httpHandlers>

    <handlers>
        <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>

    [/code]

    More info about the Charting control:
    http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx

    Enjoy charting,
    Pieter

    Asp.Net: Menu control remove MenuItem (MenuItemDataBound)

    For a project I needed to remove menu items to the pages in the folder ‘Subscriberpages’ when a the user is in the Role of ‘Marketing’ and ‘AccountManagement’. To do this I added the following code to the MenuItemDataBound event.

    
    protected void mainMenu_MenuItemDataBound(object sender, MenuEventArgs e)
    {
     SiteMapNode node = e.Item.DataItem as SiteMapNode;
    
     if (node.Url.Contains("<em>Subscriberpages</em>"))
     {
      if (HttpContext.Current.User.IsInRole("<em>Marketing</em>") || HttpContext.Current.User.IsInRole("<em>AccountManagement'</em>"))
      {
       // Get menu.
       Menu topMenu = (Menu)sender;
    
       // Remove dataitem from menu.
       topMenu.Items.Remove(e.Item);
      }
     }
    }
    
    

    To generate the menu I used the Web.sitemap and the asp:Menu control.