Commit 2b0a27e6 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
This is a marker file generated by the precompilation tool, and should not be deleted!
\ No newline at end of file
<precompiledApp version="2" updatable="false"/>
\ No newline at end of file
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<AuthorRoyalties>
<au_id>172-32-1176</au_id>
<royalty>0.03</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>213-46-8915</au_id>
<royalty>0.04</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>238-95-7766</au_id>
<royalty>0.05</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>267-41-2394</au_id>
<royalty>0.06</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>274-80-9391</au_id>
<royalty>0.07</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>341-22-1782</au_id>
<royalty>0.08</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>409-56-7008</au_id>
<royalty>0.09</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>427-17-2319</au_id>
<royalty>0.10</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>472-27-2349</au_id>
<royalty>0.01</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>486-29-1786</au_id>
<royalty>0.02</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>527-72-3246</au_id>
<royalty>0.03</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>648-92-1872</au_id>
<royalty>0.04</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>672-71-3249</au_id>
<royalty>0.05</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>712-45-1867</au_id>
<royalty>0.06</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>722-51-5454</au_id>
<royalty>0.07</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>724-08-9931</au_id>
<royalty>0.08</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>724-80-9391</au_id>
<royalty>0.09</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>756-30-7391</au_id>
<royalty>0.10</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>807-91-6654</au_id>
<royalty>0.01</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>846-92-7186</au_id>
<royalty>0.02</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>893-72-1158</au_id>
<royalty>0.03</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>899-46-2035</au_id>
<royalty>0.04</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>998-72-3567</au_id>
<royalty>0.05</royalty>
</AuthorRoyalties>
</DocumentElement>
\ No newline at end of file
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<!-- use this section to specify connection string, such as SQL Connection Strings -->
<connectionStrings>
<add name="LocalPubs" connectionString="Server=(local);Integrated Security=True;Database=pubs;Persist Security Info=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
-->
<caching>
<!-- sqlCacheDependency Attributes:
enabled="[true|false]" - Enable or disable SQL cache dependency polling
pollTime="poll time in milliseconds. Minimum is 500 ms."
Child nodes:
<databases> Database entries
<add Add a database entry
name="string" Name to identify this database entry
connectionStringName="string" Connection string name to the SQL database
pollTime="int" (optional) Poll time in milliseconds
<remove Remove a database entry
name="string" /> Name of database entry to remove
<clear/> Remove all database entries
</databases>
Example:
<databases>
<add name="Northwind_Local" connectionStringName="LocalNorthwind" />
<remove name="Pubs_Local">
<databases>
-->
<!-- for recipe 14.10 written by 14.15-->
<sqlCacheDependency enabled="true" pollTime="60000">
<databases>
<add name="pubs" connectionStringName="LocalPubs" pollTime="9000000" />
</databases>
</sqlCacheDependency>
</caching>
</system.web>
</configuration>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" />
<input id="Checkbox1" type="checkbox" />
<input id="Radio1" type="radio" />
<select id="Select1">
<option selected="selected"></option>
</select>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
using System.Web.Caching;
using System.Data.SqlClient;
using System.Diagnostics;
public partial class Default_aspx : System.Web.UI.Page
{
// Page events are wired up automatically to methods
// with the following names:
// Page_Load, Page_AbortTransaction, Page_CommitTransaction,
// Page_DataBinding, Page_Disposed, Page_Error, Page_Init,
// Page_Init Complete, Page_Load, Page_LoadComplete, Page_PreInit
// Page_PreLoad, Page_PreRender, Page_PreRenderComplete,
// Page_SaveStateComplete, Page_Unload
string _connStr = "Persist Security Info=False;Integrated Security=SSPI;" +
"database=pubs;server=localhost;Connect Timeout=30";
protected void Page_Load(object sender, EventArgs e)
{
// if the initial request
if (Request.QueryString.Count == 0)
{
// run 14.15 to add the sqlCache database entry
// to web.config
TestConfig();
// now redirect to ourselves adding a querystring
// we do this so that the change we made to
// web.config gets picked up for the code in
// CreateSqlCacheDependency and SetupCacheDependencies
// as it depends on that configuration being present.
// if you just create the entry and call the setup
// code in the same page instance, the internal
// configuration stuff doesn't refresh and you get
// an exception when the code can't find the sqlCache
// section it needs.
Response.Redirect(Request.RawUrl + "?run=1");
}
else
{
// run 14.10
CreateSqlCacheDependency(_connStr);
// run 14.11
SetupCacheDependencies(_connStr);
}
}
#region "14.10 Tying your database code to the cache"
public SqlCacheDependency CreateSqlCacheDependency(string connStr)
{
// make a dependency on the authors database table so that
// if it changes, the cached data will also be disposed of
// make sure we are enabled for notifications for the db
// note that the parameter has to be the actual connection
// string NOT the connection string NAME from web.config
SqlCacheDependencyAdmin.EnableNotifications(connStr);
// make sure we are enabled for notifications for the table
SqlCacheDependencyAdmin.EnableTableForNotifications(connStr, "Authors");
// this is case sensitive so make sure the first entry
// matches the entry in the web.config file exactly
// The first parameter here must be the connection string
// NAME not the connection string itself...
return new SqlCacheDependency("pubs", "Authors");
}
#endregion
#region "14.11 Caching data with multiple dependencies"
public void SetupCacheDependencies(string connStr)
{
// make a dependency on the authory royalties file
// so if someone updates it, the cached data will
// be disposed of
string file = this.Server.MapPath("author_royalties.xml");
CacheDependency fileDep = new CacheDependency(file);
// use our method from 14.10 to make a SqlCacheDependency
SqlCacheDependency sqlDep = CreateSqlCacheDependency(connStr);
// set up data table to get
DataSet authorInfo = null;
// look for the pubs key in the cache
// If it isn't there, create it with a dependency
// on a SQL Server table using the SqlCacheDependency class.
if (this.Cache["authorInfo"] == null)
{
// the data wasn't there so go get it and put it in the cache
authorInfo = new DataSet("AuthorInfo");
using (SqlConnection sqlConn = new SqlConnection(connStr))
{
using (SqlDataAdapter adapter =
new SqlDataAdapter("SELECT * FROM AUTHORS", sqlConn))
{
adapter.Fill(authorInfo);
// now add the royalty info
authorInfo.ReadXml(file, XmlReadMode.InferSchema);
// make the aggregate dependency so that if either the
// db or file changes, we toss this out of the cache
AggregateCacheDependency aggDep = new AggregateCacheDependency();
// add the two dependencies to the aggregate
aggDep.Add(new CacheDependency[] { sqlDep, fileDep });
// add author info dataset to cache with the aggregate
// dependency so that if either changes the cache will refetch
this.Cache.Insert("authorInfo", authorInfo, aggDep);
}
}
}
else
{
authorInfo = (DataSet)this.Cache["authorInfo"];
}
}
#endregion
#region "14.15 Inspect and change your web application configuration"
public void TestConfig()
{
try
{
// Get the web.config file for this app
System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration(@"/CSCBWeb");
// Get the sqlCacheDependencySection
SqlCacheDependencySection sqlCacheDep = (SqlCacheDependencySection)cfg.GetSection("system.web/caching/sqlCacheDependency");
// create a database entry for the sql cache
SqlCacheDependencyDatabase sqlCacheDb = new SqlCacheDependencyDatabase("pubs","LocalPubs",9000000);
// add our database entry for the caching
sqlCacheDep.Databases.Add(sqlCacheDb);
// enable it
sqlCacheDep.Enabled = true;
// poll once a minute
sqlCacheDep.PollTime = 60000;
// save our new settings to the cfg file
cfg.Save(ConfigurationSaveMode.Modified);
}
catch (Exception e)
{
Debug.WriteLine(e.ToString());
}
}
#endregion
}
\ No newline at end of file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DownloadData16_4.aspx.cs" Inherits="DownloadData16_4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form name="Form1" method="post" action="DownloadData16_4.aspx" id="Form2">
<input type="hidden" name="__VIEWSTATE"
value="dDwyMDQwNjUzNDY2Ozs+kS9hguYm9369sybDqmIow0AvxBg=" />
<span id="Label1" style="Z-INDEX: 101; LEFT: 142px; POSITION: absolute;
TOP: 164px">This is downloaded html!</span>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DownloadData16_4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CSCBWeb")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CSCBWeb")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UploadData16_4.aspx.cs" Inherits="UploadData16_4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
public partial class UploadData16_4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (string f in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[f];
// need to have write permissions for the directory to write to
try
{
string path = Server.MapPath(".") + @"\" + file.FileName;
file.SaveAs(path);
Response.Write("Saved " + path);
}
catch (HttpException hex)
{
// return error information specific to the save
Response.Write("Failed to save file with error: " +
hex.Message);
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm1.aspx.cs" Inherits="WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server" Height="139px" Width="361px">
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Label ID="Label1" runat="server" Text="Identity"></asp:Label></asp:TableCell>
<asp:TableCell runat="server"><asp:TextBox ID="Identity" runat="server"/></asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Label ID="Label2" runat="server" Text="Item"></asp:Label></asp:TableCell>
<asp:TableCell runat="server"><asp:TextBox ID="Item" runat="server"/></asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Label ID="Label3" runat="server" Text="Quantity"></asp:Label></asp:TableCell>
<asp:TableCell runat="server"><asp:TextBox ID="Quantity" runat="server"/></asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server"></asp:TableCell>
<asp:TableCell runat="server"><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" /></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
WriteOrderResponse();
}
protected void Button1_Click(object sender, EventArgs e)
{
WriteOrderResponse();
}
private void WriteOrderResponse()
{
string response = "Thanks for the order!<br/>";
response += "Identity: " + Request.Form["Identity"] + "<br/>";
response += "Item: " + Request.Form["Item"] + "<br/>";
response += "Quantity: " + Request.Form["Quantity"] + "<br/>";
Response.Write(response);
}
}
<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<AuthorRoyalties>
<au_id>172-32-1176</au_id>
<royalty>0.03</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>213-46-8915</au_id>
<royalty>0.04</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>238-95-7766</au_id>
<royalty>0.05</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>267-41-2394</au_id>
<royalty>0.06</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>274-80-9391</au_id>
<royalty>0.07</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>341-22-1782</au_id>
<royalty>0.08</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>409-56-7008</au_id>
<royalty>0.09</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>427-17-2319</au_id>
<royalty>0.10</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>472-27-2349</au_id>
<royalty>0.01</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>486-29-1786</au_id>
<royalty>0.02</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>527-72-3246</au_id>
<royalty>0.03</royalty>
</AuthorRoyalties>
<AuthorRoyalties>
<au_id>648-92-1872</au_id>