Code Samples - acastaner/harnet GitHub Wiki

Basics

Parsing a file

To parse a .har file, you need to use the HarConverter class and import the file as a string:

Log datLog = HarConverter.ImportHarContent(File.ReadAllText(filePath));

Once this is done, the file is parsed!

Entries

In HAR, an 'Entry' is a Request/Response pair. A Log usually contains several entries, saved under Log.Entries (which is of type List<Entry>)

Counting entries

int entriesCount = datLog.Entries.Count;

Iterating through entries

foreach (Entry entry in harLog.Entries) { stuff }

⚠️ **GitHub.com Fallback** ⚠️