none
Forbidden Error In Visual Basic

    Question

  • Hello, I have a program that gets weather alerts from the national weather service rss feed. It has worked great. Recently, it has been giving me forbidden errors in the program, but when I enter the URL I get the alerts from into a web browser, it displays the feed. Why is it giving me this and how can I fix?

    Here is the code:

    Using WB As New WebClient
                Try
                    Dim WXData As String = WB.DownloadString("My.Settings.NWS_Alert")
                    If WXData <> LastWXData Then
                        LastWXData = WXData
                        ListBox1.Items.Clear()
                        ListBox1.Enabled = False
                        WXDict.Clear()
                        XmlDoc.LoadXml(WXData)
                        Dim TitleList As XmlNodeList = XmlDoc.GetElementsByTagName("description")
                        Dim SummaryList As XmlNodeList = XmlDoc.GetElementsByTagName("message")
                        For i = 1 To TitleList.Count - 1
                            WXDict.Add(TitleList(i).InnerText, SummaryList(i - 1).InnerText)
                        Next
                        Label6.Text = SummaryList(0).InnerText
                        ListBox1.Items.AddRange(WXDict.Keys.ToArray)
                        ListBox1.Enabled = True
                        ListBox1.SelectedIndex = 0
                    End If
                Catch ex As Exception
                End Try
            End Using
    
    
    
        End Sub
        Dim LastWXData As String = ""

    In the first section, the link is typed into a textbox and is saved in My.Settings.NWS_Alert. Then another textbox (that is hidden) displays the link and the program grabs the information from the RSS Feed. Note: This feeds can be found at alerts.weather.gov under the atom icons next to the states or click counties for individual counties.

    Thanks!



    Wednesday, March 22, 2017 11:21 PM

All replies