RRS Problem

L

Lasse Edsvik

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
 
G

Greg Burns

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
 
G

Guest

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.
 
L

Lasse Edsvik

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>
 
G

Greg Burns

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 said:
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 said:
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
 
L

Lasse Edsvik

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 said:
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?c...code=&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 said:
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 said:
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

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
 
G

Greg Burns

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 said:
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 said:
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?c...code=&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 said:
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>




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

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
 
L

Lasse Edsvik

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 said:
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 said:
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 said:
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?c...code=&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

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?c...code=&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>




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

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
 
G

Greg Burns

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 said:
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 said:
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 said:
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>



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

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>




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

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top