Solve the problem that MS Office fails to download website data

Source: Internet
Author: User

Recently, a Web Query created in MS Excel cannot be refreshed after it is created for a period of time (or after the file is closed, the file is opened again and the data is refreshed, an error is reported when you click Refresh:

You cannot download the required information.

This is a unfriendly error. From the prompt information, it seems that the website cannot be opened, but there is no problem in opening it in the browser (using the authentication of anonymous users ).

For more error information, I checked the System Event Log and found such a record:

Object reference not set to an instance of an object. at xxx. global. session_Start (Object sender, EventArgs e) at System. web. sessionState. sessionStateModule. raiseOnStart (EventArgs e)...

It seems that an unhandled exception was thrown during access to this webpage, so I checked the Global. asax. cs file of the website, and the access object exists in the Session_Start method.

Request. the Code of Headers ["Accept-Language"]. Because the Session will exist for a period of time, the Session_Start method is not called when it is refreshed after the query is created, so I added the code to determine whether the object is empty in this method and the problem was solved.

Conclusion: When you use Office to extract data from a website, if an exception occurs on the server side on the webpage you are visiting, this type of download failure will be reported without displaying the exception details, you need to view the event logs on the server. When creating a query in the Office, accessing the website is the same as accessing the website through a browser, so the behavior and performance are consistent. After a query is created, when the website is refreshed to obtain data, some functions are simplified compared with those of the browser, for example, Headers ["Accept-Language"] does not exist in the Request sent when refreshing website data. It is analyzed by using the network packet capture software Fiddler:

Request Header information when the browser accesses the website:

The request header information when the Office software accesses the website through Web Query:

. It seems that you need to pay attention to the Web Query construction in the future. I hope this article will be helpful and instructive to the friends who encounter the same problem. You are also welcome to give your comments and supplement.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.