Reputation: 894
I am running an asp.net application with forms authentication on IIS 7 in classic mode. Logging is turned on and the cs-username field is currently selected to be logged. However, the cs-username is always blank in the logs. Anyone have tips on how to determine the cause?
Upvotes: 3
Views: 6306
Reputation: 1010
You can do the following and it will get set in theIIS
logs cs-username.
public WebApiApplication()
{
this.AuthenticateRequest += WebApiApplication_AuthenticateRequest;
}
void WebApiApplication_AuthenticateRequest(object sender, EventArgs e)
{
HttpContext.Current.User = new GenericPrincipal(new GenericIdentity("SET THE USER INFO HERE"), null);
}
Upvotes: 0
Reputation: 1
I think that you have to save the asp.net LOGGIN in a HEADER variable and use na ISAPI filter to get this information and save on the IIS_LOG.
Upvotes: 0
Reputation: 1719
What Bryan says is true. In Classic mode, you go through double authentication processes. That is, IIS authenticates you first, and then ASP.NET authenticates you. In classic mode, the IIS Authentication is likely set to anonymous, in which case, IIS will log nothing in that field. If you turn on integrated pipeline, the authentication happens only once -- and within the IIS pipeline. That means that IIS can write data to the cs-username field.
Upvotes: 1
Reputation: 8788
cs-username knows nothing about ASP.NET / forms authentication, and vice-versa... You have Anonymous access turned on in IIS, yes? That's why there is no cs-username output.
Upvotes: 5