Configuring ASP.NET
Posted on 20 Feb 2006 at 12:07
Thomas Lee looks at how to manage and configure ASP.NET, together with IIS and HTTP
As you can see, this page contains only layout and calls to process the data. When it's clicked, ASP.NET gets directed to call the Add method, but the details of what exactly is to happen are contained in the Add method's separate code-behind file. The @PAGE directive at the top of the page tells ASP.NET which code-behind file (calc.aspx.cs) contains the Add method.
calc.aspx.cs looks like this:
using System;
public partial class _Default : System.Web.UI.Page
{
protected void Add(object sender, EventArgs e) //add 2 numbers
{
int d1 = Convert.ToInt32(TextBox1.Text);
int d2 = Convert.ToInt32(TextBox2.Text);
int result = d1+d2;
Label1.Text=result.ToString();
}
protected void Sub (object sender, EventArgs e) //subtract 2 numbers
{
int d1 = Convert.ToInt32(TextBox1.Text);
int d2 = Convert.ToInt32(TextBox2.Text);
int result = d1-d2;
Label1.Text=result.ToString();
}
}
When you first request calc.aspx in your browser, the web server sends the HTML page, which includes an HTML form. When you click on either of its buttons, the browser sends the information you enter into the two textboxes back to the server, along with an indication of which button was pressed. Once the request is received at the server, ASP.NET orchestrates calling the appropriate method (the Add method if you clicked the first button).
Configuring ASP.NET
You can configure ASP.NET in three separate places:
IIS Manager MMC snap-in: use IIS Manager to configure general web app settings required for your ASP.NET app, to configure app pools and add or remove websites from your system.
ASP.NET configuration files: ASP.NET uses a hierarchy of web.config files, which apply only to ASP.NET resources.
Page code: some configuration items are actually contained in the web page itself; for example, in the <@Page...> directive. You can disable HTTP response buffering using the Buffer attribute (http://msdn.microsoft.com/ library/default.asp?url=/library/en-us/cpgenref/html/cpconPage.asp)
For the most part, though, you'll be configuring ASP.NET apps in web.config. .NET provides a single machine.config file, which holds master settings applying to all apps running on the same computer, located in:
%systemroot%\Microsoft.NET\
where
If the application URL is multilevel, as in myserver/a/b/c/calc.asp, you can have a web.config file in each of the virtual folders in the URL path - that is, /a/web.config, /a/b/web.config and /a/b/c/web.config - where values specified lower in the virtual path override values higher up. There's also a 'no override' feature to avoid lower-level web.config values overriding those higher up where necessary. And ASP.NET blocks any request for web.config files, so you can only view them via the PC's own file system, not remotely.
From around the web
advertisement
- Why virtualisation hasn't slowed the growth of data
- How to make Google AdWords work for your business
- The curse of sloppily written software
- Paying for your crimes with Bitcoin
- Behind the scenes: tech support for Formula 1
- The security risk of fat fingers
- Why Windows Phone 7 isn't quite ready for business
- When will Microsoft stop fiddling with Windows 8?
- Flash down the pan?
- Metro Style apps vs desktop applications
- Chrome's shine getting lost in translation
- BytePac: the cardboard hard disk enclosure
- How tech loosens our grip on reality
- Hokum watch: Safer Internet Day
- Why I'm deleting Adobe from my PC
- Prepare to be patronised: it's Safer Internet Day
- Dear Sony, Samsung and every other tech company in the world: stop trying to be Apple
- Will Apple's Final Cut Pro X update placate the pros?
- Smartr Contacts for iPhone review
- Switching to Office 365's Outlook Web App
- VeriSign slammed for security breach cover-up
- SAP willing to share HANA with Oracle
- Why using a tablet could harm your health
- New RIM boss: no need for drastic change
- RIM founders fall on their swords
- Slow economy helps boost Red Hat revenue by 23%
- Google+ pages get multiple admins
- One in five companies lack card industry compliance
- Oil industry warns hacking attacks could kill
- British workers fear email monitoring
advertisement

