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.
advertisement
- Getting to grips with Microsoft's IT Health Environment Scanner
- Virtualise your servers
- The changing face of travel gadgets
- Build your own distributed file system
- The bulletproof Dell that costs an arm and a leg
- Microsoft Office 2010 Technical Preview: Q&A
- Lawnmowers, the TyTN II and one odd insurance request
- There'll never be a bulletproof OS
- How far can we trust apps?
- Five nice touches in Outlook 2010
- Why Britain's watchdogs have fewer teeth than goldfish
- Tabbed documents: how to make Office 2010 great
- Outlook 2010 People Pane – does it spell death to Xobni
- Microsoft Outlook 2010 screenshots
- Co-Authoring in Word 2010 and SharePoint Foundation 2010
- Microsoft Outlook 2010 screenshots: Backstage view
- Flash 10.1: Developing for Desktop and Device
- Microsoft Office 2010 screenshots: Recover unsaved items
- Microsoft Word 2010 screenshots: Text Effects
- Microsoft Word 2010: inserting screenshots
- Q&A: Why Conficker was a victim of its own success
- App developers losing faith in Android
- Biz Stone: Murdoch's Google veto will "fail fast"
- Google adds automatic captions to YouTube
- China ramps up cyber spying
- Mozilla maintains dependence on Google
- Windows 7 flying off the shelves
- Google Chrome OS: full details unveiled
- AOL slashes 2,500 jobs
- YouTube begins streaming full-length shows
advertisement
Printed from www.pcpro.co.uk


