I want to print to log basic information about the site that my IIS
service is running under.
Any suggestions/examples how it can be done?
Add the following code to your page load event, then navigate to the page. You should find the output useful, and it's handy for evaluating the differences between web server enclaves.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
try
dim outputString as string = string.empty
outputString = "Server: " & HttpContext.Current.Server.MachineName.ToString() & "<br/>"
outputString = outputString & ".Net version: " & Environment.Version.ToString() & "<br/>"
outputString = outputString & "machine config file directory: " & System.web.HttpRuntime.MachineConfigurationDirectory.ToString() & "<br/>"
outputString = outputString & "<br/>"
outputString = outputString & "security principal user: " & System.Security.Principal.WindowsIdentity.GetCurrent().Name & "<br/>"
outputString = outputString & "computer (server) logon user identity: " & Request.LogonUserIdentity.Name & "<br/>"
outputString = outputString & "login in user identity: " & System.Windows.Forms.SystemInformation.UserName.ToString() & "<br/>"
outputString = outputString & "app: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString() & "<br/>"
outputString = outputString & "<br/>"
outputString = outputString & "app version: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() & "<br/>"
outputString = outputString & "windows forms application product version: " & System.Windows.Forms.Application.ProductVersion & "<br/>"
'outputString = outputString & "context items: " & HttpContext.Current.items.ToString() & "<br/>"
outputString = outputString & "app domain id: " & System.web.HttpRuntime.AppDomainAppId.ToString() & "<br/>"
outputString = outputString & "<br/>"
outputString = outputString & "app domain app path: " & System.web.HttpRuntime.AppDomainAppPath.ToString() & "<br/>"
outputString = outputString & "app domain virtual path: " & System.web.HttpRuntime.AppDomainAppVirtualPath.ToString() & "<br/>"
outputString = outputString & "client script physical path: " & System.web.HttpRuntime.AspClientScriptPhysicalPath.ToString() & "<br/>"
outputString = outputString & "client script virtual path: " & System.web.HttpRuntime.AspClientScriptVirtualPath.ToString() & "<br/>"
outputString = outputString & "<br/>"
outputString = outputString & "asp install directory: " & System.web.HttpRuntime.AspInstallDirectory.ToString() & "<br/>"
outputString = outputString & "Common language runtime directory: " & System.web.HttpRuntime.ClrInstallDirectory.ToString() & "<br/>"
outputString = outputString & "Code gen directory: " & System.web.HttpRuntime.CodegenDir.ToString() & "<br/>"
lblOutput.text = outputString
catch ex as exception
lblOutput.text = ex.tostring
end try
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With