Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Checking out a Web Server’s Custom Error Pages
|
825
14.18 Checking out a Web Server’s Custom Error Pages
Problem
You have an application that needs to know what custom error pages are set up for
the various HTTP error return codes on a given IIS server.
Solution
Use the System.DirectoryServices.DirectoryEntry class to talk to the Internet Infor-
mation Server (IIS) metabase to find out which custom error pages are set up. The
metabase holds the configuration information for the web server.
DirectoryEntry
uses the Active Directory IIS service provider to communicate with the metabase by
specifying the
"IIS" scheme in the constructor for the DirectoryEntry.
// This is a case-sensitive entry in the metabase.
// You'd think it was misspelled but you would be mistaken...
const string WebServerSchema = "IIsWebServer";
// Set up to talk to the local IIS server.
string server = "localhost";
// Create a dictionary entry for the IIS server with a fake
// user and password. Credentials would have to be provided
// if you are running as a regular user.
using (DirectoryEntry w3svc =
new DirectoryEntry(
string.Format("IIS://{0}/w3svc", server),
"Domain/UserCode", "Password"))
{
Once the connection is established, the web server schema entry is specified to show
where the IIS settings are kept (
IIsWebServer ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata