Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of

From the author of

Installing the Custom Module

There is one last step that you must complete before you can use the new module in an application. You must add the new module to the <httpModules> section in either the Machine.Config or Web.Config file.

If you need to use the module with only one application, then you'll want to add the Web.Config file contained in Listing 9 to the root directory of your application:

Listing 9—Web.Config File

<configuration>
<system.web>
 <httpModules>
  <add name="XmlAuthentication" 
   type="XmlAuthenticationModule, XmlAuthenticationModule"/>
 </httpModules>
</system.web>
</configuration>

After you add the entry for the XmlAuthenticationModule to the Web.Config file, the module will execute whenever someone requests any page from the application.

You can test the module by attempting to request a page with different query string parameters. For example, if you assign bob to the guests role in the XmlRoles.xml file, and you don't associate guests with the Private.aspx page in the XmlAuthRoles.xml file, then you'll receive the message Forbidden! when attempting to retrieve the page with the following request:

http://localhost/myApp/Private.aspx?userID=bob

You can also test the XmlAuthenticationModule by making changes directly to the XmlRoles.xml file and the XmlAuthorRoles.xml file. For example, if you assign the user bob to the administrators role, then he should then be able to request the Private.aspx page.

  • + Share This
  • 🔖 Save To Your Account