Invalid URI error during web test run

The HTML of most web pages requires a collection of other files to be downloaded, such as images, JSON, CSS, JavaScript, etc. These are the dependant requests. Visual Studio examines the HTML to find the set of dependant requests. They should all be valid URLs. The Visual Studio code that extracts these dependant requests is less forgiving than many browsers. Visual Studio requires them to be valid URLs. Many real browsers work hard to cope with bad HTML so that something sensible can be shown.

The reason for the exception is probably badly formatted HTML in the response. Some browsers have developer facilities that will describe errors found in the downloaded html. Check what these developer facilities say about errors on the page; it may be worth trying several browsers to get different assessments of the page.

One example: a malformed base tag can lead to the exception you report.


When looking at the web test execution log for a successful request you will see the dependant requests listed. It appears that Visual Studio "trusts" that these requests form valid URLs, ie they are properly formatted. Your test has a badly formatted URL. If you had given a properly formatted URL but there was no resource then you would have seen the dependant request and seen it get 404 error. This is an edge case and you might argue that Visual Studio should report it differently.

By "web test execution log" I refers to the way the results of a web test are shown. That is the tabular form with the column titles: Request + Status + Total time + Request time + Request bytes + Response bytes. Below that there are tabs showing details of the selected item, the tabs are labelled Web browser + Request + Response + Context + Details. If you click the little triangles at the left-hand side of the "Request" column you will see the redirections and the dependant requests. (Note that logs for web tests run within a load test omit dependant request details.)


Setting "Parse Dependent Requests" to False for that specific call helps.