Trouble pulling RSS/XML in C# (Forbidden) -
i have snippet of code has been working fine until week ago, , errors out , exception says 403 forbidden. have been reading maybe adding "defaultcredentials" may help, not sure how apply code.
i trying pull info from: http://na.leagueoflegends.com/en/rss.xml
and code working fine is:
xdocument xmlfile = xdocument.load(@"http://na.leagueoflegends.com/en/rss.xml"); var loltitles = service in xmlfile.descendants("item") select (string)service.element("title"); var lollinks = service in xmlfile.descendants("item") select (string)service.element("link"); var loldescriptions = service in xmlfile.descendants("item") select (string)service.element("description"); var loldates = service in xmlfile.descendants("item") select (string)service.element("pubdate"); var servicing = loldescriptions.toarray(); (int = 0; < 4; i++) { servicing[i] = regex.replace(server.htmldecode(servicing[i]), @"<[^>]*>", string.empty); } viewbag.titles = loltitles.toarray(); viewbag.links = lollinks.toarray(); viewbag.descriptions = servicing; viewbag.dates = loldates.toarray();
but xdocument.load line getting forbidden exception. can still manually go .xml's url page , see file/text, not sure why programme beingness denied access of sudden...
i have browsed around , trying figure out how default credentials approach people have used url/web requests, not know how tack onto xdocument (or equivalent approach).
c# xml rss linq-to-xml
No comments:
Post a Comment