RRS Problem

Discussion in 'ASP .Net' started by Lasse Edsvik, Sep 22, 2004.

  1. Lasse Edsvik

    Lasse Edsvik Guest

    Hello

    I was wondering how to solve this issue....

    I have a weather RSS that i retrieve xml from..... and it only allows me to
    get data once each hour, so if i reload my page i get an error, how to
    resolve that?

    TIA
    /Lasse
     
    Lasse Edsvik, Sep 22, 2004
    #1
    1. Advertising

  2. Lasse Edsvik

    Greg Burns Guest

    Sounds like a good use for the Cache object. When you first load it shove it
    in Cache object and set an expiration of 1 hour. On every page load check
    to see if Cache object is nothing, if it is then hour should be up so reload
    it...

    Greg

    "Lasse Edsvik" <> wrote in message
    news:%23ggUJ$...
    > Hello
    >
    > I was wondering how to solve this issue....
    >
    > I have a weather RSS that i retrieve xml from..... and it only allows me
    > to
    > get data once each hour, so if i reload my page i get an error, how to
    > resolve that?
    >
    > TIA
    > /Lasse
    >
    >
     
    Greg Burns, Sep 22, 2004
    #2
    1. Advertising

  3. Cache the data in a file or database. I was going to suggest caching in the
    application object but if the server has to get rebooted you will lose any
    data in the appliaction cache.
     
    =?Utf-8?B?U2NvdHQgU2ltb25z?=, Sep 22, 2004
    #3
  4. Lasse Edsvik

    Lasse Edsvik Guest

    Greg,

    how do i put caching on and set it to like 61 minutes?

    I started with .net yesterday so i have no clue lol

    here is my code:


    <%@ Page Language="C#" Debug="true" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Xml" %>
    <script runat="server">

    void Page_Load(object sender, EventArgs e)
    {
    RssWeather.DataSource =
    GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    =rss20a");
    RssWeather.DataBind();
    }

    private DataTable GetRSSFeed(string strURL)
    {
    DataSet ds = new DataSet();
    ds.ReadXml(strURL);
    return ds.Tables[2];
    }
    </script>
    <html>
    <head>
    <title>Untitled</title>
    </head>
    <body>
    <asp:DataGrid id="RssWeather" Width="100%"
    AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    runat="server">
    <Columns>
    <asp:TemplateColumn HeaderText="Weather Forecast">
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "title") %><br/>
    <%# DataBinder.Eval(Container.DataItem, "description") %>

    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
    </body>
    </html>




    "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    news:ufFG%...
    > Sounds like a good use for the Cache object. When you first load it shove

    it
    > in Cache object and set an expiration of 1 hour. On every page load check
    > to see if Cache object is nothing, if it is then hour should be up so

    reload
    > it...
    >
    > Greg
    >
    > "Lasse Edsvik" <> wrote in message
    > news:%23ggUJ$...
    > > Hello
    > >
    > > I was wondering how to solve this issue....
    > >
    > > I have a weather RSS that i retrieve xml from..... and it only allows me
    > > to
    > > get data once each hour, so if i reload my page i get an error, how to
    > > resolve that?
    > >
    > > TIA
    > > /Lasse
    > >
    > >

    >
    >
     
    Lasse Edsvik, Sep 22, 2004
    #4
  5. Lasse Edsvik

    Greg Burns Guest

    In VB and untested (sorry)...

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    If Not IsPostBack Then

    BindGrid()

    End If

    End Sub


    Private Sub BindGrid()


    Dim dsWeather As DataSet = CType(Cache.Get("WeatherCache"), DataSet)

    If dsWeather Is Nothing Then
    'Response.Write("<b>Dynamically Created</b><p>")

    dsWeather =
    GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    =rss20a")


    ' refreshes dataset if 61 minutes goes by since cached
    Cache.Insert("WeatherCache", dsWeather, Nothing,
    DateTime.Now.AddMinutes(61), Cache.NoSlidingExpiration)


    Dim dv As New DataView(dsWeather.Tables(0))

    RssWeather.DataSource = dv
    RssWeather.DataBind()


    Else
    'Response.Write("<b>From Cache</b><p>")
    Dim dv As New DataView(dsWeather.Tables(0))

    RssWeather.DataSource = dv
    RssWeather.DataBind()
    End If
    End Sub

    Greg

    "Lasse Edsvik" <> wrote in message
    news:%23b%...
    > Greg,
    >
    > how do i put caching on and set it to like 61 minutes?
    >
    > I started with .net yesterday so i have no clue lol
    >
    > here is my code:
    >
    >
    > <%@ Page Language="C#" Debug="true" %>
    > <%@ import Namespace="System.Data" %>
    > <%@ import Namespace="System.Xml" %>
    > <script runat="server">
    >
    > void Page_Load(object sender, EventArgs e)
    > {
    > RssWeather.DataSource =
    > GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    > hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    > =rss20a");
    > RssWeather.DataBind();
    > }
    >
    > private DataTable GetRSSFeed(string strURL)
    > {
    > DataSet ds = new DataSet();
    > ds.ReadXml(strURL);
    > return ds.Tables[2];
    > }
    > </script>
    > <html>
    > <head>
    > <title>Untitled</title>
    > </head>
    > <body>
    > <asp:DataGrid id="RssWeather" Width="100%"
    > AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    > HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    > HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    > Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    > runat="server">
    > <Columns>
    > <asp:TemplateColumn HeaderText="Weather Forecast">
    > <ItemTemplate>
    > <%# DataBinder.Eval(Container.DataItem, "title")
    > %><br/>
    > <%# DataBinder.Eval(Container.DataItem, "description") %>
    >
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:DataGrid>
    > </body>
    > </html>
    >
    >
    >
    >
    > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    > news:ufFG%...
    >> Sounds like a good use for the Cache object. When you first load it shove

    > it
    >> in Cache object and set an expiration of 1 hour. On every page load
    >> check
    >> to see if Cache object is nothing, if it is then hour should be up so

    > reload
    >> it...
    >>
    >> Greg
    >>
    >> "Lasse Edsvik" <> wrote in message
    >> news:%23ggUJ$...
    >> > Hello
    >> >
    >> > I was wondering how to solve this issue....
    >> >
    >> > I have a weather RSS that i retrieve xml from..... and it only allows
    >> > me
    >> > to
    >> > get data once each hour, so if i reload my page i get an error, how to
    >> > resolve that?
    >> >
    >> > TIA
    >> > /Lasse
    >> >
    >> >

    >>
    >>

    >
    >
     
    Greg Burns, Sep 22, 2004
    #5
  6. Lasse Edsvik

    Lasse Edsvik Guest

    I used this, still it "contacts" that server and doesnt use cache :(


    <%@ Page Language="C#" Debug="true" %>
    <%@OutputCache Duration="900" VaryByParam="none" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Xml" %>
    <script runat="server">

    void Page_Load(object sender, EventArgs e)
    {
    RssWeather.DataSource =
    GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    =rss20a");
    RssWeather.DataBind();
    }

    private DataTable GetRSSFeed(string strURL)
    {
    DataSet ds = new DataSet();
    ds.ReadXml(strURL);
    return ds.Tables[2];
    }
    </script>
    <html>
    <head>
    <title>Untitled</title>
    </head>
    <body>
    <asp:DataGrid id="RssWeather" Width="100%"
    AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    runat="server">
    <Columns>
    <asp:TemplateColumn HeaderText="Weather Forecast - Philadelphia
    County">
    <ItemTemplate>
    <b><%# DataBinder.Eval(Container.DataItem, "title")
    %></b><br/>
    <%# DataBinder.Eval(Container.DataItem, "description") %>

    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
    </body>
    </html>



    "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    news:...
    > In VB and untested (sorry)...
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    >
    > If Not IsPostBack Then
    >
    > BindGrid()
    >
    > End If
    >
    > End Sub
    >
    >
    > Private Sub BindGrid()
    >
    >
    > Dim dsWeather As DataSet = CType(Cache.Get("WeatherCache"),

    DataSet)
    >
    > If dsWeather Is Nothing Then
    > 'Response.Write("<b>Dynamically Created</b><p>")
    >
    > dsWeather =
    >

    GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >

    hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    > =rss20a")
    >
    >
    > ' refreshes dataset if 61 minutes goes by since cached
    > Cache.Insert("WeatherCache", dsWeather, Nothing,
    > DateTime.Now.AddMinutes(61), Cache.NoSlidingExpiration)
    >
    >
    > Dim dv As New DataView(dsWeather.Tables(0))
    >
    > RssWeather.DataSource = dv
    > RssWeather.DataBind()
    >
    >
    > Else
    > 'Response.Write("<b>From Cache</b><p>")
    > Dim dv As New DataView(dsWeather.Tables(0))
    >
    > RssWeather.DataSource = dv
    > RssWeather.DataBind()
    > End If
    > End Sub
    >
    > Greg
    >
    > "Lasse Edsvik" <> wrote in message
    > news:%23b%...
    > > Greg,
    > >
    > > how do i put caching on and set it to like 61 minutes?
    > >
    > > I started with .net yesterday so i have no clue lol
    > >
    > > here is my code:
    > >
    > >
    > > <%@ Page Language="C#" Debug="true" %>
    > > <%@ import Namespace="System.Data" %>
    > > <%@ import Namespace="System.Xml" %>
    > > <script runat="server">
    > >
    > > void Page_Load(object sender, EventArgs e)
    > > {
    > > RssWeather.DataSource =
    > >

    GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    > >

    hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    > > =rss20a");
    > > RssWeather.DataBind();
    > > }
    > >
    > > private DataTable GetRSSFeed(string strURL)
    > > {
    > > DataSet ds = new DataSet();
    > > ds.ReadXml(strURL);
    > > return ds.Tables[2];
    > > }
    > > </script>
    > > <html>
    > > <head>
    > > <title>Untitled</title>
    > > </head>
    > > <body>
    > > <asp:DataGrid id="RssWeather" Width="100%"
    > > AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    > > HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    > > HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    > > Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    > > runat="server">
    > > <Columns>
    > > <asp:TemplateColumn HeaderText="Weather Forecast">
    > > <ItemTemplate>
    > > <%# DataBinder.Eval(Container.DataItem, "title")
    > > %><br/>
    > > <%# DataBinder.Eval(Container.DataItem, "description") %>
    > >
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > > </Columns>
    > > </asp:DataGrid>
    > > </body>
    > > </html>
    > >
    > >
    > >
    > >
    > > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    > > news:ufFG%...
    > >> Sounds like a good use for the Cache object. When you first load it

    shove
    > > it
    > >> in Cache object and set an expiration of 1 hour. On every page load
    > >> check
    > >> to see if Cache object is nothing, if it is then hour should be up so

    > > reload
    > >> it...
    > >>
    > >> Greg
    > >>
    > >> "Lasse Edsvik" <> wrote in message
    > >> news:%23ggUJ$...
    > >> > Hello
    > >> >
    > >> > I was wondering how to solve this issue....
    > >> >
    > >> > I have a weather RSS that i retrieve xml from..... and it only allows
    > >> > me
    > >> > to
    > >> > get data once each hour, so if i reload my page i get an error, how

    to
    > >> > resolve that?
    > >> >
    > >> > TIA
    > >> > /Lasse
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
     
    Lasse Edsvik, Sep 22, 2004
    #6
  7. Lasse Edsvik

    Greg Burns Guest

    Cache can be tricky to debug. Are you using VS.NET? Certain things will
    reset your app, hence reset the cache.

    900 seconds = 15 minutes (just to be clear)

    If you cache the entire page like that, you cannot have any dynamic things
    going on (i.e. no postbacks to the page). Depends on your needs, I guess.

    Try getting the cache thing to work with a simple Reponse.Write(Now()) in
    the page load, once you know it is working then add the call to the
    webservice.

    Greg


    "Lasse Edsvik" <> wrote in message
    news:...
    >I used this, still it "contacts" that server and doesnt use cache :(
    >
    >
    > <%@ Page Language="C#" Debug="true" %>
    > <%@OutputCache Duration="900" VaryByParam="none" %>
    > <%@ import Namespace="System.Data" %>
    > <%@ import Namespace="System.Xml" %>
    > <script runat="server">
    >
    > void Page_Load(object sender, EventArgs e)
    > {
    > RssWeather.DataSource =
    > GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    > hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    > =rss20a");
    > RssWeather.DataBind();
    > }
    >
    > private DataTable GetRSSFeed(string strURL)
    > {
    > DataSet ds = new DataSet();
    > ds.ReadXml(strURL);
    > return ds.Tables[2];
    > }
    > </script>
    > <html>
    > <head>
    > <title>Untitled</title>
    > </head>
    > <body>
    > <asp:DataGrid id="RssWeather" Width="100%"
    > AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    > HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    > HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    > Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    > runat="server">
    > <Columns>
    > <asp:TemplateColumn HeaderText="Weather Forecast - Philadelphia
    > County">
    > <ItemTemplate>
    > <b><%# DataBinder.Eval(Container.DataItem, "title")
    > %></b><br/>
    > <%# DataBinder.Eval(Container.DataItem, "description") %>
    >
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:DataGrid>
    > </body>
    > </html>
    >
    >
    >
    > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    > news:...
    >> In VB and untested (sorry)...
    >>
    >> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    >> System.EventArgs) Handles MyBase.Load
    >> 'Put user code to initialize the page here
    >>
    >> If Not IsPostBack Then
    >>
    >> BindGrid()
    >>
    >> End If
    >>
    >> End Sub
    >>
    >>
    >> Private Sub BindGrid()
    >>
    >>
    >> Dim dsWeather As DataSet = CType(Cache.Get("WeatherCache"),

    > DataSet)
    >>
    >> If dsWeather Is Nothing Then
    >> 'Response.Write("<b>Dynamically Created</b><p>")
    >>
    >> dsWeather =
    >>

    > GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >>

    > hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >> =rss20a")
    >>
    >>
    >> ' refreshes dataset if 61 minutes goes by since cached
    >> Cache.Insert("WeatherCache", dsWeather, Nothing,
    >> DateTime.Now.AddMinutes(61), Cache.NoSlidingExpiration)
    >>
    >>
    >> Dim dv As New DataView(dsWeather.Tables(0))
    >>
    >> RssWeather.DataSource = dv
    >> RssWeather.DataBind()
    >>
    >>
    >> Else
    >> 'Response.Write("<b>From Cache</b><p>")
    >> Dim dv As New DataView(dsWeather.Tables(0))
    >>
    >> RssWeather.DataSource = dv
    >> RssWeather.DataBind()
    >> End If
    >> End Sub
    >>
    >> Greg
    >>
    >> "Lasse Edsvik" <> wrote in message
    >> news:%23b%...
    >> > Greg,
    >> >
    >> > how do i put caching on and set it to like 61 minutes?
    >> >
    >> > I started with .net yesterday so i have no clue lol
    >> >
    >> > here is my code:
    >> >
    >> >
    >> > <%@ Page Language="C#" Debug="true" %>
    >> > <%@ import Namespace="System.Data" %>
    >> > <%@ import Namespace="System.Xml" %>
    >> > <script runat="server">
    >> >
    >> > void Page_Load(object sender, EventArgs e)
    >> > {
    >> > RssWeather.DataSource =
    >> >

    > GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >> >

    > hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >> > =rss20a");
    >> > RssWeather.DataBind();
    >> > }
    >> >
    >> > private DataTable GetRSSFeed(string strURL)
    >> > {
    >> > DataSet ds = new DataSet();
    >> > ds.ReadXml(strURL);
    >> > return ds.Tables[2];
    >> > }
    >> > </script>
    >> > <html>
    >> > <head>
    >> > <title>Untitled</title>
    >> > </head>
    >> > <body>
    >> > <asp:DataGrid id="RssWeather" Width="100%"
    >> > AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    >> > HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    >> > HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    >> > Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    >> > runat="server">
    >> > <Columns>
    >> > <asp:TemplateColumn HeaderText="Weather Forecast">
    >> > <ItemTemplate>
    >> > <%# DataBinder.Eval(Container.DataItem, "title")
    >> > %><br/>
    >> > <%# DataBinder.Eval(Container.DataItem, "description") %>
    >> >
    >> > </ItemTemplate>
    >> > </asp:TemplateColumn>
    >> > </Columns>
    >> > </asp:DataGrid>
    >> > </body>
    >> > </html>
    >> >
    >> >
    >> >
    >> >
    >> > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    >> > news:ufFG%...
    >> >> Sounds like a good use for the Cache object. When you first load it

    > shove
    >> > it
    >> >> in Cache object and set an expiration of 1 hour. On every page load
    >> >> check
    >> >> to see if Cache object is nothing, if it is then hour should be up so
    >> > reload
    >> >> it...
    >> >>
    >> >> Greg
    >> >>
    >> >> "Lasse Edsvik" <> wrote in message
    >> >> news:%23ggUJ$...
    >> >> > Hello
    >> >> >
    >> >> > I was wondering how to solve this issue....
    >> >> >
    >> >> > I have a weather RSS that i retrieve xml from..... and it only
    >> >> > allows
    >> >> > me
    >> >> > to
    >> >> > get data once each hour, so if i reload my page i get an error, how

    > to
    >> >> > resolve that?
    >> >> >
    >> >> > TIA
    >> >> > /Lasse
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
     
    Greg Burns, Sep 22, 2004
    #7
  8. Lasse Edsvik

    Lasse Edsvik Guest

    Greg,

    not using VS.NET, cant afford it.....


    it caches the output but it contacts that RSS thingy and gives me an error
    since output changes when Ive reloaded like 3 times...... yep, it should be
    15 minutes.....


    "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    news:...
    > Cache can be tricky to debug. Are you using VS.NET? Certain things will
    > reset your app, hence reset the cache.
    >
    > 900 seconds = 15 minutes (just to be clear)
    >
    > If you cache the entire page like that, you cannot have any dynamic things
    > going on (i.e. no postbacks to the page). Depends on your needs, I guess.
    >
    > Try getting the cache thing to work with a simple Reponse.Write(Now()) in
    > the page load, once you know it is working then add the call to the
    > webservice.
    >
    > Greg
    >
    >
    > "Lasse Edsvik" <> wrote in message
    > news:...
    >>I used this, still it "contacts" that server and doesnt use cache :(
    >>
    >>
    >> <%@ Page Language="C#" Debug="true" %>
    >> <%@OutputCache Duration="900" VaryByParam="none" %>
    >> <%@ import Namespace="System.Data" %>
    >> <%@ import Namespace="System.Xml" %>
    >> <script runat="server">
    >>
    >> void Page_Load(object sender, EventArgs e)
    >> {
    >> RssWeather.DataSource =
    >> GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >> hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >> =rss20a");
    >> RssWeather.DataBind();
    >> }
    >>
    >> private DataTable GetRSSFeed(string strURL)
    >> {
    >> DataSet ds = new DataSet();
    >> ds.ReadXml(strURL);
    >> return ds.Tables[2];
    >> }
    >> </script>
    >> <html>
    >> <head>
    >> <title>Untitled</title>
    >> </head>
    >> <body>
    >> <asp:DataGrid id="RssWeather" Width="100%"
    >> AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    >> HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    >> HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    >> Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    >> runat="server">
    >> <Columns>
    >> <asp:TemplateColumn HeaderText="Weather Forecast -
    >> Philadelphia
    >> County">
    >> <ItemTemplate>
    >> <b><%# DataBinder.Eval(Container.DataItem, "title")
    >> %></b><br/>
    >> <%# DataBinder.Eval(Container.DataItem, "description") %>
    >>
    >> </ItemTemplate>
    >> </asp:TemplateColumn>
    >> </Columns>
    >> </asp:DataGrid>
    >> </body>
    >> </html>
    >>
    >>
    >>
    >> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    >> news:...
    >>> In VB and untested (sorry)...
    >>>
    >>> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    >>> System.EventArgs) Handles MyBase.Load
    >>> 'Put user code to initialize the page here
    >>>
    >>> If Not IsPostBack Then
    >>>
    >>> BindGrid()
    >>>
    >>> End If
    >>>
    >>> End Sub
    >>>
    >>>
    >>> Private Sub BindGrid()
    >>>
    >>>
    >>> Dim dsWeather As DataSet = CType(Cache.Get("WeatherCache"),

    >> DataSet)
    >>>
    >>> If dsWeather Is Nothing Then
    >>> 'Response.Write("<b>Dynamically Created</b><p>")
    >>>
    >>> dsWeather =
    >>>

    >> GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >>>

    >> hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >>> =rss20a")
    >>>
    >>>
    >>> ' refreshes dataset if 61 minutes goes by since cached
    >>> Cache.Insert("WeatherCache", dsWeather, Nothing,
    >>> DateTime.Now.AddMinutes(61), Cache.NoSlidingExpiration)
    >>>
    >>>
    >>> Dim dv As New DataView(dsWeather.Tables(0))
    >>>
    >>> RssWeather.DataSource = dv
    >>> RssWeather.DataBind()
    >>>
    >>>
    >>> Else
    >>> 'Response.Write("<b>From Cache</b><p>")
    >>> Dim dv As New DataView(dsWeather.Tables(0))
    >>>
    >>> RssWeather.DataSource = dv
    >>> RssWeather.DataBind()
    >>> End If
    >>> End Sub
    >>>
    >>> Greg
    >>>
    >>> "Lasse Edsvik" <> wrote in message
    >>> news:%23b%...
    >>> > Greg,
    >>> >
    >>> > how do i put caching on and set it to like 61 minutes?
    >>> >
    >>> > I started with .net yesterday so i have no clue lol
    >>> >
    >>> > here is my code:
    >>> >
    >>> >
    >>> > <%@ Page Language="C#" Debug="true" %>
    >>> > <%@ import Namespace="System.Data" %>
    >>> > <%@ import Namespace="System.Xml" %>
    >>> > <script runat="server">
    >>> >
    >>> > void Page_Load(object sender, EventArgs e)
    >>> > {
    >>> > RssWeather.DataSource =
    >>> >

    >> GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >>> >

    >> hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >>> > =rss20a");
    >>> > RssWeather.DataBind();
    >>> > }
    >>> >
    >>> > private DataTable GetRSSFeed(string strURL)
    >>> > {
    >>> > DataSet ds = new DataSet();
    >>> > ds.ReadXml(strURL);
    >>> > return ds.Tables[2];
    >>> > }
    >>> > </script>
    >>> > <html>
    >>> > <head>
    >>> > <title>Untitled</title>
    >>> > </head>
    >>> > <body>
    >>> > <asp:DataGrid id="RssWeather" Width="100%"
    >>> > AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    >>> > HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    >>> > HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    >>> > Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    >>> > runat="server">
    >>> > <Columns>
    >>> > <asp:TemplateColumn HeaderText="Weather Forecast">
    >>> > <ItemTemplate>
    >>> > <%# DataBinder.Eval(Container.DataItem, "title")
    >>> > %><br/>
    >>> > <%# DataBinder.Eval(Container.DataItem, "description") %>
    >>> >
    >>> > </ItemTemplate>
    >>> > </asp:TemplateColumn>
    >>> > </Columns>
    >>> > </asp:DataGrid>
    >>> > </body>
    >>> > </html>
    >>> >
    >>> >
    >>> >
    >>> >
    >>> > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    >>> > news:ufFG%...
    >>> >> Sounds like a good use for the Cache object. When you first load it

    >> shove
    >>> > it
    >>> >> in Cache object and set an expiration of 1 hour. On every page load
    >>> >> check
    >>> >> to see if Cache object is nothing, if it is then hour should be up so
    >>> > reload
    >>> >> it...
    >>> >>
    >>> >> Greg
    >>> >>
    >>> >> "Lasse Edsvik" <> wrote in message
    >>> >> news:%23ggUJ$...
    >>> >> > Hello
    >>> >> >
    >>> >> > I was wondering how to solve this issue....
    >>> >> >
    >>> >> > I have a weather RSS that i retrieve xml from..... and it only
    >>> >> > allows
    >>> >> > me
    >>> >> > to
    >>> >> > get data once each hour, so if i reload my page i get an error, how

    >> to
    >>> >> > resolve that?
    >>> >> >
    >>> >> > TIA
    >>> >> > /Lasse
    >>> >> >
    >>> >> >
    >>> >>
    >>> >>
    >>> >
    >>> >
    >>>
    >>>

    >>
    >>

    >
    >
     
    Lasse Edsvik, Sep 22, 2004
    #8
  9. Lasse Edsvik

    Greg Burns Guest

    But if you are REALLY caching the whole page, Page_Load will NOT run! Hence,
    put the response.write(Now()) statement in your page load, that way you can
    see if it is truely caching or not. (The time will change on every refresh
    if not caching).

    Obviously, it is not caching for you. But I am not sure if WebMatrix(?)
    resets the cache on every "start" or not...

    That OutputCache directive looks correct to me.

    Greg

    "Lasse Edsvik" <> wrote in message
    news:...
    > Greg,
    >
    > not using VS.NET, cant afford it.....
    >
    >
    > it caches the output but it contacts that RSS thingy and gives me an error
    > since output changes when Ive reloaded like 3 times...... yep, it should
    > be 15 minutes.....
    >
    >
    > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    > news:...
    >> Cache can be tricky to debug. Are you using VS.NET? Certain things will
    >> reset your app, hence reset the cache.
    >>
    >> 900 seconds = 15 minutes (just to be clear)
    >>
    >> If you cache the entire page like that, you cannot have any dynamic
    >> things going on (i.e. no postbacks to the page). Depends on your needs,
    >> I guess.
    >>
    >> Try getting the cache thing to work with a simple Reponse.Write(Now()) in
    >> the page load, once you know it is working then add the call to the
    >> webservice.
    >>
    >> Greg
    >>
    >>
    >> "Lasse Edsvik" <> wrote in message
    >> news:...
    >>>I used this, still it "contacts" that server and doesnt use cache :(
    >>>
    >>>
    >>> <%@ Page Language="C#" Debug="true" %>
    >>> <%@OutputCache Duration="900" VaryByParam="none" %>
    >>> <%@ import Namespace="System.Data" %>
    >>> <%@ import Namespace="System.Xml" %>
    >>> <script runat="server">
    >>>
    >>> void Page_Load(object sender, EventArgs e)
    >>> {
    >>> RssWeather.DataSource =
    >>> GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >>> hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >>> =rss20a");
    >>> RssWeather.DataBind();
    >>> }
    >>>
    >>> private DataTable GetRSSFeed(string strURL)
    >>> {
    >>> DataSet ds = new DataSet();
    >>> ds.ReadXml(strURL);
    >>> return ds.Tables[2];
    >>> }
    >>> </script>
    >>> <html>
    >>> <head>
    >>> <title>Untitled</title>
    >>> </head>
    >>> <body>
    >>> <asp:DataGrid id="RssWeather" Width="100%"
    >>> AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    >>> HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    >>> HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    >>> Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    >>> runat="server">
    >>> <Columns>
    >>> <asp:TemplateColumn HeaderText="Weather Forecast -
    >>> Philadelphia
    >>> County">
    >>> <ItemTemplate>
    >>> <b><%# DataBinder.Eval(Container.DataItem, "title")
    >>> %></b><br/>
    >>> <%# DataBinder.Eval(Container.DataItem, "description") %>
    >>>
    >>> </ItemTemplate>
    >>> </asp:TemplateColumn>
    >>> </Columns>
    >>> </asp:DataGrid>
    >>> </body>
    >>> </html>
    >>>
    >>>
    >>>
    >>> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    >>> news:...
    >>>> In VB and untested (sorry)...
    >>>>
    >>>> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    >>>> System.EventArgs) Handles MyBase.Load
    >>>> 'Put user code to initialize the page here
    >>>>
    >>>> If Not IsPostBack Then
    >>>>
    >>>> BindGrid()
    >>>>
    >>>> End If
    >>>>
    >>>> End Sub
    >>>>
    >>>>
    >>>> Private Sub BindGrid()
    >>>>
    >>>>
    >>>> Dim dsWeather As DataSet = CType(Cache.Get("WeatherCache"),
    >>> DataSet)
    >>>>
    >>>> If dsWeather Is Nothing Then
    >>>> 'Response.Write("<b>Dynamically Created</b><p>")
    >>>>
    >>>> dsWeather =
    >>>>
    >>> GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >>>>
    >>> hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >>>> =rss20a")
    >>>>
    >>>>
    >>>> ' refreshes dataset if 61 minutes goes by since cached
    >>>> Cache.Insert("WeatherCache", dsWeather, Nothing,
    >>>> DateTime.Now.AddMinutes(61), Cache.NoSlidingExpiration)
    >>>>
    >>>>
    >>>> Dim dv As New DataView(dsWeather.Tables(0))
    >>>>
    >>>> RssWeather.DataSource = dv
    >>>> RssWeather.DataBind()
    >>>>
    >>>>
    >>>> Else
    >>>> 'Response.Write("<b>From Cache</b><p>")
    >>>> Dim dv As New DataView(dsWeather.Tables(0))
    >>>>
    >>>> RssWeather.DataSource = dv
    >>>> RssWeather.DataBind()
    >>>> End If
    >>>> End Sub
    >>>>
    >>>> Greg
    >>>>
    >>>> "Lasse Edsvik" <> wrote in message
    >>>> news:%23b%...
    >>>> > Greg,
    >>>> >
    >>>> > how do i put caching on and set it to like 61 minutes?
    >>>> >
    >>>> > I started with .net yesterday so i have no clue lol
    >>>> >
    >>>> > here is my code:
    >>>> >
    >>>> >
    >>>> > <%@ Page Language="C#" Debug="true" %>
    >>>> > <%@ import Namespace="System.Data" %>
    >>>> > <%@ import Namespace="System.Xml" %>
    >>>> > <script runat="server">
    >>>> >
    >>>> > void Page_Load(object sender, EventArgs e)
    >>>> > {
    >>>> > RssWeather.DataSource =
    >>>> >
    >>> GetRSSFeed("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=p
    >>>> >
    >>> hiladelphia+county&state=pa&zipcode=&country=us&county=42101&zone=PAZ071&alt
    >>>> > =rss20a");
    >>>> > RssWeather.DataBind();
    >>>> > }
    >>>> >
    >>>> > private DataTable GetRSSFeed(string strURL)
    >>>> > {
    >>>> > DataSet ds = new DataSet();
    >>>> > ds.ReadXml(strURL);
    >>>> > return ds.Tables[2];
    >>>> > }
    >>>> > </script>
    >>>> > <html>
    >>>> > <head>
    >>>> > <title>Untitled</title>
    >>>> > </head>
    >>>> > <body>
    >>>> > <asp:DataGrid id="RssWeather" Width="100%"
    >>>> > AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-Font-Size="12pt"
    >>>> > HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
    >>>> > HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="True"
    >>>> > Font-Size="8pt" Font-Name="Arial" AutoGenerateColumns="false"
    >>>> > runat="server">
    >>>> > <Columns>
    >>>> > <asp:TemplateColumn HeaderText="Weather Forecast">
    >>>> > <ItemTemplate>
    >>>> > <%# DataBinder.Eval(Container.DataItem, "title")
    >>>> > %><br/>
    >>>> > <%# DataBinder.Eval(Container.DataItem, "description") %>
    >>>> >
    >>>> > </ItemTemplate>
    >>>> > </asp:TemplateColumn>
    >>>> > </Columns>
    >>>> > </asp:DataGrid>
    >>>> > </body>
    >>>> > </html>
    >>>> >
    >>>> >
    >>>> >
    >>>> >
    >>>> > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
    >>>> > news:ufFG%...
    >>>> >> Sounds like a good use for the Cache object. When you first load it
    >>> shove
    >>>> > it
    >>>> >> in Cache object and set an expiration of 1 hour. On every page load
    >>>> >> check
    >>>> >> to see if Cache object is nothing, if it is then hour should be up
    >>>> >> so
    >>>> > reload
    >>>> >> it...
    >>>> >>
    >>>> >> Greg
    >>>> >>
    >>>> >> "Lasse Edsvik" <> wrote in message
    >>>> >> news:%23ggUJ$...
    >>>> >> > Hello
    >>>> >> >
    >>>> >> > I was wondering how to solve this issue....
    >>>> >> >
    >>>> >> > I have a weather RSS that i retrieve xml from..... and it only
    >>>> >> > allows
    >>>> >> > me
    >>>> >> > to
    >>>> >> > get data once each hour, so if i reload my page i get an error,
    >>>> >> > how
    >>> to
    >>>> >> > resolve that?
    >>>> >> >
    >>>> >> > TIA
    >>>> >> > /Lasse
    >>>> >> >
    >>>> >> >
    >>>> >>
    >>>> >>
    >>>> >
    >>>> >
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Greg Burns, Sep 22, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,981
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,155
    Ted Miller
    Sep 13, 2003
  3. Merek
    Replies:
    0
    Views:
    1,964
    Merek
    Dec 3, 2003
  4. Scott Meddows
    Replies:
    1
    Views:
    391
    John Saunders
    Jun 8, 2004
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    550
    Bullschmidt
    May 11, 2004
Loading...

Share This Page