views:

102

answers:

1

Hello,

I've developed a WinForms app that I've that shows the bandwidth a single IIS site using LogParser. This worked quite well.

I've now written the exact same thing in ASP.net, but then the following exception is thrown: Cannot find any file matching "C:\inetpub\logs\LogFiles\W3SVC4\ex*.log"

The exception makes sence, since all our log files are prefixed with 'u_ex' and not 'ex' (default IIS settings I guess). It's just strange that it does work when ran from a WinForms application and not when put in a WebApp.

Does anyone know why this happens and how I can fix it?

Thanks!

Here's a chuck of the code I'm using:

private void UpdateByDateRange(DateTime dateFrom, DateTime dateTo) 
{

string siteId = Request.ServerVariables["INSTANCE_ID"]; 
LogQueryClassClass logger = new LogQueryClassClass();

COMIISW3CInputContextClass inputContext = new COMIISW3CInputContextClassClass(); 
string query = "SELECT SUM(TO_REAL(sc-bytes)) AS sentTotal, SUM(TO_REAL(cs-bytes)) AS receivedTotal FROM <" + siteId + "> WHERE TO_TIMESTAMP(date, time) >= TO_TIMESTAMP('" + dateFrom.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH:mm:ss') AND TO_TIMESTAMP(date, time) <= TO_TIMESTAMP('" + dateTo.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH:mm:ss')";

ILogRecord record = logger.Execute(query, inputContext).getRecord(); 
decimal trafficSent = decimal.Parse(record.getValue("sentTotal").ToString());

decimal trafficReceived = decimal.Parse(record.getValue("receivedTotal").ToString()); 
// ...

}
A: 

Does AspNet have permissions to the C:\inetpub\logs\LogFiles\W3SVC4\ folder? This error normally occurs when the file doesn't exist OR the runtime does not have permissions. As an Asp.Net app, you need to ensure that the AspNet account has access to this folder or run the web site under another account that does have access.

This older post might help.

http://stackoverflow.com/questions/85941/aspnet-user-does-not-have-write-access-to-temporary-asp-net-files

David Stratton
Thanks for your reply. I am pretty sure my rights are correct sincea) Security was the first problem I came across and had fixed before I ran into this problem.and b) The exception makes sence (there are no files prefixed with ex)
Tijs Hendriks