You are on page 1of 3

<?xml version="1.0" encoding="utf-8" ?

> <CDLIST> <XMLTITLE>My CD Collections</XMLTITLE> <CD> <TITLE>Spider-Man 3</TITLE> <ARTIST>Tobey Maguire</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Sony Pictures</COMPANY> <PRICE>20.90</PRICE> <YEAR>2007</YEAR> </CD> <CD> <TITLE>The Pink Panther</TITLE> <ARTIST>Steve Martin</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>MGM Distribution Company</COMPANY> <PRICE>17.90</PRICE> <YEAR>2006</YEAR> </CD> <CD> <TITLE>Mission: Impossible III </TITLE> <ARTIST>Tom Cruise</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Paramount Pictures</COMPANY> <PRICE>12.90</PRICE> <YEAR>2006</YEAR> </CD> <CD> <TITLE>Indepence Day</TITLE> <ARTIST>Will Smith</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia Pictures</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> </CDLIST> XSLT file <h2> <xsl:value-of select="CDList/XmlTitle" /> </h2> <table width="500" border="1"> <xsl:for-each select="CDList/CD"> <tr> <td> <b>Title: <xsl:value-of select="TITLE" /> </b><br /> Artist: <xsl:value-of select="ARTIST" /><br />

Country: <xsl:value-of select="COUNTRY" /><br /> Company: <xsl:value-of select="COMPANY" /><br /> Price: $ <xsl:value-of select="PRICE" /><br /> Year: <xsl:value-of select="YEAR" /> </td> </tr> </xsl:for-each> </table> protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { bool Authenticated = false; Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserNam e, Login1.Password); e.Authenticated = Authenticated; if (Authenticated == true) { Response.Redirect("~//Media//Media.aspx"); } } private bool SiteLevelCustomAuthenticationMethod(string username, string password) { bool boolReturnValue = false; if (username.ToLower().Equals("me") && password.ToLower().Equals("abc123")) boolReturnValue = true; return boolReturnValue; } (Of course I will change the code in SiteLevelCustomAuthenticationMethod to either connect to database, or read an xml file and match username password. ) This worked but the problem I was having was that the users could still browse to "Media/Media.aspx" manually and it would allow them. I then added the following to my web.config: <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <appSettings/> <connectionStrings/> <system.web> <compilation debug="true"/> <authorization> <allow users="*"/> </authorization>

<authentication mode="Forms"> <forms name=".ASPXAUTH" loginUrl="RegisterLogin.aspx" protection="Validation" timeout="999999"/> </authentication> </system.web> <location path="Media"> <system.web> <compilation debug="true"/> <authorization> <deny users="?"/> </authorization> </system.web> </location> </configuration>

You might also like