<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">nunos's Blog</title><subtitle type="html">Exploring .NET</subtitle><id>http://blogs.msdn.com/nunos/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/nunos/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2004-03-12T10:20:00Z</updated><entry><title>A sa(i)mple Online Exam Engine on ASP.NET</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2005/02/17/375200.aspx" /><id>http://blogs.msdn.com/nunos/archive/2005/02/17/375200.aspx</id><published>2005-02-17T19:33:00Z</published><updated>2005-02-17T19:33:00Z</updated><content type="html">&lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Some time ago, a customer that attended my MSDN session, asked me to help him developing an online exam engine. They wanted something simple that retrieved questions from a database or a file and allowed employees to take some online exams.&amp;nbsp;In order to simplify deployment, they wanted&amp;nbsp;to do this&amp;nbsp;on ASP.NET&amp;nbsp;and SQL Server.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;As I browsed in the internet, I did find a few samples but none that completely satisfied me. So, for the exercise, I decided to develop my own sample in a way that each of its components could be changed with ease. So, I decided to use a standard three tier model: presentation, business logic and data access.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;For the presentation layer, I decided to use a simple&amp;nbsp;ASP.NET web user control (ascx). This allows you to&amp;nbsp;simply drag the control to your page to use it and also allows&amp;nbsp;you to customize the display with the help of the VS.NET IDE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The business logic layer is the one that I believe you will not want to change much. Possibly add a few things. I did the sample for illustration purposes. It's not intended to be a full-scale online exam engine, but rather a starting point&amp;nbsp;for developing your own.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The data access layer is actually the one you&amp;nbsp;WILL want to change. In order to get the sample working&amp;nbsp;in a way you can test it with ease, I&amp;nbsp;retrieve the exam questions from an xml file.&amp;nbsp;I built this layer (QuestionRetriever.cs) in a way that it uses very simple methods to get simple pieces of information (number of questions, get question number x, time limit for this exam, etc.) so you shouldn't have any problems changing this methods to get the same data from a SQL server or another database engine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;This was the main concern when developing the sample: build the exam engine in a way that the physical location of the data is irrelevant.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;You can test the sample here: &lt;a href="http://nunosilva.members.winisp.net/samples/working/OnlineExamEngine/"&gt;http://nunosilva.members.winisp.net/samples/working/OnlineExamEngine/&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The xml file that is used to generate this exam can be found here: &lt;a href="http://nunosilva.members.winisp.net/samples/working/OnlineExamEngine/math.xml"&gt;http://nunosilva.members.winisp.net/samples/working/OnlineExamEngine/math.xml&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The zip file containing the sample can be found here: &lt;a href="http://nunosilva.members.winisp.net/samples/OnlineExamEngine.zip"&gt;http://nunosilva.members.winisp.net/samples/OnlineExamEngine.zip&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Drilling down a bit, let's look at some of the main features here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The ascx basically is responsible for displaying the exam from start to finish. To use it, you simply drag and drop it into a page. Then you must declare it in your code-behind file. The only thing that I don’t like here is you have to name it myQuestion1…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Why? Well, I do use some JavaScript to implement the timer. We set the timer to an initial value, the timer decrements itself each second and when it reaches 0, disables the buttons and sends the user to the scoring report. To implement this, and because I’m not a JavaScript expert, I have to reference the buttons and other controls on the page by its id. The problem is that, because we’re in a user control, ASP.NET renders all controls inside it with the user control name as a prefix (e.g. myQuestion1_timer) to avoid collisions. So, when I need to reference a control in JavaScript by its id, I have to make sure the user control name is a particular one. Of course you can choose another name but you’ll have to change the JavaScript yourself. By the way, if someone has a suggestion on how to change this please post a comment to this post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;After you declare the control, you set a property called exam_url that specifies where the exam file (xml) is located. One way to quickly change this to SQL server is setting this property to the exam id on the database and change the data access layer to access the database instead of a file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Buy as far as using the sample as is that’s all you have to do: put the control on the page and specify where the exam is found. Nice!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The business logic tier defines a set of classes that encapsulate all the exams logic. It has objects that represent a question, an answer and has all the logic needed to advance to next question, score the exam, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The code is pretty self-explanatory although there are some tricks I had to use mostly related to the interaction between the JavaScript timer and my server side code. However, of course you are free to ask me questions about this sample.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Hope this code might prove useful to you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=375200" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>Storing images in a database - MSDN session related</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/12/09/278894.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/12/09/278894.aspx</id><published>2004-12-09T22:22:00Z</published><updated>2004-12-09T22:22:00Z</updated><content type="html">&lt;span lang="EN" style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Well, after receiving lots of feedback about the code used in the MSDN sessions in November, I seem to have forgotten something. In the title generation sample in which we retrieve one of several images from the database (the one currently selected as the site title template) and use a handler to write the string with the desired title over it, most users seem to be faced with the following problem: how do we get images in a database in the first place.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Well, it's not really difficult: you can create a stream that points to the file, read the bytes and store them in an Image column in the db (assuming SQL Server or MSDE for this). Here is an example on how to do this&amp;nbsp;in an&amp;nbsp;ASP.NET&amp;nbsp;application, more specifically, in a File Upload page. This makes sense because one of the other samples was about a digital photo sharing web application, so you might want to integrate both things.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The first thing you need to do is create&amp;nbsp;a new webform in your asp.net application, and add the following piece of code to your HTML form declaration:&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="BACKGROUND: whitesmoke; MARGIN: 0cm 0cm 12pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&lt;br /&gt;&lt;span style="COLOR: red"&gt;enctype&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="multipart/form-data"&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The next thing you need to do is add an HtmlInputFile. To do this, open the toolbox, choose the Html Tag and add the File Field control. Then, right-click the control and check "Run as a server control" (this basically just adds the runat="server" in the HTML declaration and declares the control in the code-behind file).&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;You're almost there! What we just did&amp;nbsp;was preparing the web form to receive uploaded files.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Now add a Button control (ASP.NET button control) and doble click it to write the event handler for the click event.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Add this code to your web form:&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="BACKGROUND: whitesmoke; MARGIN: 0cm 0cm 0pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; mso-ansi-language: EN-GB"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;private&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, System.EventArgs e)&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;font face="Times New Roman"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;{&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;SqlConnection cn = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; SqlConnection("server=&amp;lt;server_name&amp;gt;;database=&amp;lt;database_name&amp;gt;;user ID=&amp;lt;user_id&amp;gt;;password=&amp;lt;password&amp;gt;");&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;SqlCommand cmd = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; SqlCommand("INSERT INTO Pictures (name,type,picture_data) VALUES (@name,@type,@data)", cn);&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;cmd.Parameters.Add("@name", SqlDbType.VarChar,50);&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;cmd.Parameters.Add("@type", SqlDbType.VarChar,50);&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;cmd.Parameters.Add("@data", SqlDbType.Image);&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;byte&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;[] data = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[filMyFile.PostedFile.InputStream.Length];&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Request.Files[0].InputStream.Read(data, 0, (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;) Request.Files[0].InputStream.Length);&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;cmd.Parameters["@data"].Value = data;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;string&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; aux = filMyFile.PostedFile.FileName;&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;string&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; name = aux.Substring(aux.LastIndexOf("\\")+1);&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;cmd.Parameters["@name"].Value = name;&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;cmd.Parameters["@type"].Value = filMyFile.PostedFile.ContentType;&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;cn.Open();&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;cmd.ExecuteNonQuery();&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="BACKGROUND: whitesmoke"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;cn.Close();&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="BACKGROUND: whitesmoke; MARGIN: 0cm 0cm 0pt"&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Ok, this code doesn't perform any error handling so I leave that your exercise. Be sure to replace the correct values in the connection string.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;The InputStream property that we use here is in fact a System.IO.Stream. In this case the stream is created for us through the HtmlInputFile control. If you want to do this in a console or windows forms application, you can create the Stream yourself, point it to a file and use the rest of the code in a similar fashion.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;So, in the database we will store the name of the file, the type (jpeg, gif, etc) and the data itself. This actually can be used to store any type of file in the database. We keep the content type stored with the file because when we&amp;nbsp;use a page or handler&amp;nbsp;to retrieve one of these files, we need to set the correct response content type before writing the data to the response stream, so that the browser can understand what is sent to him.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;That is all. If you have any questions about the code feel free to comment the post or send me an email.&lt;/span&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;Cheers&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana"&gt;Edit: Slight correction: if you intend to put other content besides image in the database, the column type used should not be "image" but "binary". Of course you would have to change the parameter in the code above.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"&gt;&lt;span style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=278894" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>MSDN Session - Sample Code</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/12/03/274359.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/12/03/274359.aspx</id><published>2004-12-04T00:09:00Z</published><updated>2004-12-04T00:09:00Z</updated><content type="html">&lt;p&gt;Ok, as promised, here is the code that I used in the MSDN session: &lt;a href="http://nunosilva.members.winisp.net/samples/CustomPipelineDemo.zip"&gt;http://nunosilva.members.winisp.net/samples/CustomPipelineDemo.zip&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Any questions you might have about it, either post a comment to this post, or send me an email.&lt;/p&gt; &lt;p&gt;Have fun!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=274359" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>November MSDN event in Portugal</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/11/26/270635.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/11/26/270635.aspx</id><published>2004-11-26T17:50:00Z</published><updated>2004-11-26T17:50:00Z</updated><content type="html">&lt;p&gt;Well, it's been three great days acting as a speaker at the MSDN event in Portugal. My session was about extending ASP.NET with Http Handlers, Modules and SOAP Extensions and we held the event in three cities in Portugal: Aveiro, Porto and Lisboa. Besides my session, that was targeted to asp.net developers, we had sessions about WSE 2.0 (WS-Security), a very practical session about Debugging (all kinds of debugging: scripts, web services, post mortem debugging, etc) and we rapped-up the event with a session about deployment and maintenaince of .NET applications.&lt;/p&gt; &lt;p&gt;If you're following my posts you see that I recently&amp;nbsp;started writing an article about the asp.net pipeline. That article will cover all the information that my session contained and hopefully I will be able to finish it next week. The samples that I used in my session have been highly requested and, because I don't work well without deadlines, I promise I will at least post the link to a zip file containing all the code and some documentation to make it work until December, 3&lt;sup&gt;rd&lt;/sup&gt;.&lt;/p&gt; &lt;p&gt;I would like to take this opportunity to thank everyone involved in the event: the other speakers&amp;nbsp;with whom I learned so much in the last few days, the support staff that made everything be ready when we needed to, and obviously the audience that gave&amp;nbsp;us&amp;nbsp;great feedback&amp;nbsp;about the sessions and the event in general.&lt;/p&gt; &lt;p&gt;So, drop by at the end of&amp;nbsp;next week to check out the code.&amp;nbsp;You can get the slides now by visiting&amp;nbsp;&lt;a href="http://www.microsoft.com/portugal/msdn"&gt;http://www.microsoft.com/portugal/msdn&lt;/a&gt;&amp;nbsp;(portuguese only :))&amp;nbsp;&lt;/p&gt; &lt;p&gt;Thanks for attending!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=270635" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author></entry><entry><title>Great article on Http Handlers and Modules</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/11/03/251557.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/11/03/251557.aspx</id><published>2004-11-03T17:33:00Z</published><updated>2004-11-03T17:33:00Z</updated><content type="html"> &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN-GB"&gt;I'm still writing part 2 and 3 of the "Let's Extend ASP.NET" article. I'll really try to post at least part 2 until the end of the week but I can make no promises. In the meantime, if you want to look further, there's a MSDN article that shows a great implementation of Http Modules and Handlers to build an error logging mechanism. This is actually one of the common utilizations of Http Modules but they did a great job in this specific implementation allowing you to view the error log in a web interface or even as a rss feed. Cool!&lt;br /&gt; &lt;br /&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: Verdana;"&gt;&lt;a href="http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/elmah.asp"&gt;&lt;span style="" lang="EN-GB"&gt;http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/elmah.asp&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=251557" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>Let's Extend ASP.NET (part 1 of 3)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/10/27/248517.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/10/27/248517.aspx</id><published>2004-10-27T23:18:00Z</published><updated>2004-10-27T23:18:00Z</updated><content type="html">&lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;I’m currently preparing a session for a MSDN event in &lt;st1:country-region w:st="on"&gt;&lt;st1:place w:st="on"&gt;Portugal&lt;/st1:place&gt;&lt;/st1:country-region&gt; about Http Handlers, Http Modules and SOAP extensions. I actually never touched the subject until the request for the session came in, so I was really unaware of the possibilities this kind of components offers us. So, when I started to dig in the subject I can honestly say that I was amazed.&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;“Once upon a time” I had to develop an ISAPI extension to perform some URL redirection and I didn’t like the experience that much. Of course, you always end up being proud of the result if it actually works, but the development experience was far from enjoyable. The .NET components covered in this article allow you to perform most of the functions you would require in ISAPI extensions while giving you the flexibility and the great development experience you already expect when working with .NET.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;I have to say that none of the information contained in this article is ground-breaking. I used a lot of resources available on the internet and compiled it into a single, comprehensive article that should shed some light over this all-too-often forgotten subject. Specifically most of my starting knowledge came from the Michelle Bustamante’s TechEd 2004 Session on Extending ASP.NET. Michelle has a very good technical web log where you can find a lot of good examples on using these components &lt;a href="http://www.dasblonde.net/"&gt;www.dasblonde.net&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;I divided this article in three parts. In the first I shall cover most of the theory around these components and the ASP.NET pipeline. The second part focus on how you can develop and configure the components, what interfaces should be implemented, what methods you should use, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Finally, on the third part of this article I will give practical examples that will show you how we can use this knowledge to build useful and reusable components that integrate with our web applications. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;So, let’s start by understanding how a request gets handled by asp.net in the first place.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;When IIS receives a request it will look in the configurations included in its metabase to find out if some sort of special processing should me made. These configurations are actually application mappings that associate resources to ISAPI extensions. All .NET resources (*.aspx, *.asmx, *.resx, etc.) are mapped to an unmanaged ISAPI extension called aspnet_isapi.dll. The function of this dll is to pass requests to asp.net runtime so that they can be handled in our .NET managed code. This is the default configuration but can be extended according to our needs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;This means that only the resources that are mapped to this specific ISAPI extension will be handled by ASP.NET. And this is important because you have to understand the scope of the rules you define in your application configuration files (machine.config and web.config). I’ll give an example on this subject: imagine you have an ASP.NET application in a virtual directory in IIS. That application consists of aspx pages, some images (gifs, jpegs) and a web.config file. All pretty standard. In your web.config file you define the following rule:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;authorization&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;deny&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;users&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="?" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;authorization&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;What will happen if you open a browser and access an aspx page belonging to this application? As you might expect, unless you can provide some sort of credentials that identify you in the application, your request will not be authorized. But what if you change the URL to reference an image file in the same vdir? Your request will always be satisfied no matter if you provided credentials or not. Why? Because IIS is not configured to hand over the processing of these resources to ASP.NET by default, meaning that the configuration files will not affect this request. Actually, the ASP.NET runtime won’t even know that this request ever existed, because IIS will handle it directly.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Thankfully, we can configure IIS in order to change this behaviour. As you probably guessed, we have to map the required extensions to the aspnet_isapi.dll. That way, the requests will cross the boundary to ASP.NET for processing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;When that happens, ASP.NET will get an HttpApplication object that will be responsible for determining how this request will get processed. This decision will be based on the configuration that you define in machine.config or web.config. Actually what the HttpApplication object does is choosing an HttpHandler or an HttpHandlerFactory object that will in fact process the request and generate the corresponding response.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;It may or may not come as a surprise to you, but actually all requests are eventually processed by an Http Handler. Confused? What about the pages that you developed? Well, these are handlers also. As you may know, every aspx page has an object that represents the functionality included in its code behind. This object will always inherit from the Page class that in turn implements an interface called IHttpHandler. So even you’re first Hello World page is actually an Http handler. So you see, this cannot be too complicated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;If you look at machine.config you’ll see the following section:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;httpHandlers&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;add&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;verb&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;path&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*.aspx"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;type&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="System.Web.UI.PageHandlerFactory"/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;add&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;verb&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*" &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;path&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="trace.axd" &lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt;t&lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;ype&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="System.Web.Handlers.TraceHandler"/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;add&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;verb&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;path&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*.config"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;type&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="System.Web.HttpForbiddenHandler"/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;httpHandlers&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;There are a lot more handlers defined but these will be enough to explain things for now. What this means is that after the mapping at IIS level where it’s decided if a request should be handed over to ASP.NET, there is a second level of mapping, internal to ASP.NET where you assign resources to the components that process them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;In the first mapping you see that all aspx extensions are processed by the PageHandlerFactory. Why a factory? You use a factory when you have several HttpHandler objects available to process the same type of request and you have to make a decision on which one will be used. The page access example is probably the best one I can give you: so, every page has its own code behind object that we now know implements a handler. The job of the PageHandlerFactory is actually to create an instance of that object and pass it to the ASP.NET runtime so that the request can be processed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;In the second example you see that requests targeting trace.axd will be processed by TraceHandler. If you used tracing you know what these requests are. Trace.axd shows you the all the tracing information of your application and it’s used mostly on troubleshooting asp.net applications when in production. Instead of configuring the trace at page-level (which would show you the information on the bottom of the page), you can define it at the application level and view it in trace.axd. Have you ever wondered how this works since the trace.axd file is nowhere to be found on your application? The answer is above: all requests for a trace.axd file will be handled by a component called TraceHandler that dynamically gathers all the info and outputs it in the response stream. So, as you can see the resource doesn’t have to exist if the component that processes the requests that target it doesn’t actually need its contents.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;In the third mapping that I presented, all config files are mapped to the HttpForbiddenHandler. The job of this handler is simply to throw an exception. That is the mechanism that prohibits your web.config file to be served by IIS. If this wasn’t configured then IIS would simply serve the file when requested. So remember, IIS is configured to pass requests for *.config resources to ASP.NET. And ASP.NET in turn is configured to use this handler that generates an exception when it receives this kind of requests. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;So what does the extension of a resource mean? Actually nothing after the application gets built and deployed. It is just a routing mechanism. Let’s try a simple example. Create a new ASP.NET Web Application in Visual Studio and call it HandlerTest. Add a WebForm called TestExtension.aspx. Add the following code on the code-behind file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;private&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, System.EventArgs e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Response.Write(“My really stupid extension test”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Build your application and then rename TestExtension.aspx to TestExtension.rse (where ‘rse’ means Really Stupid Extension &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: Wingdings;" lang="EN"&gt;&lt;span style=""&gt;J&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;). Try to access TestExtension.rse in Internet Explorer. Nothing shows up right? IIS served the request by sending the contents of the file and the Page_Load method didn’t run. Now add a mapping in IIS for .rse extensions to the aspnet_isapi.dll. Finally add the following information to your web.config file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 8pt; color: maroon; font-family: Verdana;" lang="EN"&gt;add&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;verb&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;path&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="*.rse"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: red; font-family: Verdana;" lang="EN"&gt;type&lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;="System.Web.UI.PageHandlerFactory"&lt;/span&gt;&lt;span style="font-size: 8pt; color: fuchsia; font-family: Verdana;" lang="EN"&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; color: blue; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Now refresh the page. It worked! Why? Because we mapped the rse extensions to the same handler factory used by aspx applications, so our code-behind object will be created and the method will be executed. This will work for any aspx page no matter how complicated it is.&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Now that we understand how the routing of a request is made until it reaches the component that processes it, let’s look at the components that we can use to extend this behaviour.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;b style=""&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Http Modules&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;: these are components that are able to interact with the HTTP request throughout the entire round-trip. Meaning, they are not suited to generate a response per-se but are actually there so that you can perform some additional processing over the request and usually build-up some information and include it in the HttpContext object so that it is available for your page or web service to access. Modules can be used for many things and we’ll see in part two that in fact there are already a bunch of modules configured by default that implement things like Session State Management, Windows Authentication, Output Cache management and so on.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;b style=""&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Http Handlers&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;: this is a special type of component that is responsible for actually processing a request and generating a response. We know that handlers are created when we develop a page or a web service. So, why would we want to create new custom handlers? To create custom endpoints in our application. In part three you’ll see how we can create a handler for jpeg files that generates thumbnails when we request the image with a specific parameter in the query string or simply sends the flat image if no parameter is specified. You can also create handlers for xml files so you can turn them into reports instead of just sending the xml contents as a response to the browser.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;b style=""&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;Http Handler Factories&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;: a component that chooses one handler based on request specifics. Used when you have several handlers available to process the same type of request.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;b style=""&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;SOAP Extensions: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;a component that only applies to web services invocation and that allows you to interact with the request in the serialization/deserialization stages&lt;b style=""&gt;. &lt;/b&gt;Soap extensions are commonly used to encrypt/decrypt the request and the response to provide secure communication, to log invalid messages in their original format or even to enforce authentication by checking information that is sent out of band in a Soap Header (like user credentials).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&amp;nbsp;&lt;br /&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;The following image sums up what we've talked about so far and shows how these components relate in a round-trip. The image presents the pipeline used for processing aspx and asmx resources:&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;o:p&gt;&lt;br /&gt; &lt;br /&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;img src="http://img94.exs.cx/img94/2231/aspnetpipeline.png" alt="Image Hosted by ImageShack.us" /&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: Verdana;" lang="EN"&gt;&lt;br /&gt; This covers the subject that makes up part one of this article. I hope to be able to post the remaining parts in the next few days. Yes, I know it’s long but things will start to get more interesting once we get to the actual code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=248517" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>Redirect web services at run time</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/07/28/199482.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/07/28/199482.aspx</id><published>2004-07-28T19:24:00Z</published><updated>2004-07-28T19:24:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Well, this is not an advanced topic or anything like it. Actually it's a very simple thing to do. However, every so often I run into someone who is developing and consuming web services and don't know about this.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;So here comes&amp;nbsp;a typical scenario: you are developing a multi-tier application and some interactions between your tiers are done through web services. You develop the web service on your dev machine, you then consume it from an application also on your local machine. To do this you add a web reference to your local web service and everything just works. However, you are faced with the following problem (the common question that I'm getting a lot lately): when in production my tiers won't be in the same machine. I don't know the ip of the web services machine so, how can I prepare my application so it can work in that scenario? And, if the machine changes after some time, how can I update my application's web reference without recompiling?&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Other typical scenario would be using the same web service but having to make a decision at runtime about the specific machine that will be used.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Ok....this is very simple and actually you should use this practice even in a situation that you perfectly control all your application deployment and maintenance.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-US"&gt; &lt;/SPAN&gt;&lt;SPAN lang=EN-US style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-US"&gt;So&amp;#8230;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; how to do it?&lt;/SPAN&gt;&lt;SPAN lang=EN-US style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Let's get one thing straight right from the start: when you add a web reference you're not binding your client application to that specific URL. This operation is only intended to get the wsdl and creating the proxy class so you can get all the method and data type&amp;nbsp;information you need to use the web service. After this, what you actually do is a soap request that can be directed anywhere.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;Let's start by creating an entrance in web.config that configures your web service endpoint (meaning the URL). To do this, add the following section to your web.config file:&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: maroon; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;configuration&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="COLOR: blue; mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: maroon; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;appSettings&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: maroon; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;add&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: fuchsia; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; &lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: red; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;key&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;="WebServicesUrl"&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: fuchsia; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; &lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: red; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;value&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;="http://x.x.x.x/Services/books.asmx"&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: fuchsia; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; &lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: maroon; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;appSettings&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: maroon; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;configuration&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;You should use the&amp;nbsp;appSettings section&amp;nbsp;to set some values that are used within your application and subject to change overtime. This way, you can change them at runtime because they are read using the ConfigurationSettings.AppSettings property as we shall see.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;So, if you look at the code of your proxy class, you see that there is a property called 'Url'. Yes, that's just it. To find this you have to set the option in Solution Explorer to 'Show All Files', expand your web reference, expand Reference.map, and inside Reference.cs you'll find something like this:&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;public&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; Books() {&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;this&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;.Url = "&lt;/SPAN&gt;&lt;A href="http://x.x.x.x/Services/books.asmx"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;http://x.x.x.x/Services/books.asmx&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;";&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;}&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;We see that in the constructor of the proxy class a reference is set to specify where the web service is located. &lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;So, you see that an easy way to do this is just to replace this code with the following lines:&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;public&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt; Books() {&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; COLOR: blue; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;this&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;.Url = ConfigurationSettings.AppSettings["WebServicesUrl"]&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;}&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;This way, if the web service changes location you can simply change the web.config file to update your application on-the-fly. Because this property is also publicly available, you can also change it&amp;nbsp;before invoking the web service methods.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="FONT-SIZE: 7.5pt; FONT-FAMILY: Verdana; mso-ansi-language: EN-GB"&gt;So, like&amp;nbsp;I said...it's pretty simple...no rocket science...but hopefully it will help some of you.&lt;/SPAN&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN lang=EN-GB style="mso-ansi-language: EN-GB"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=199482" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>How to create a "Loading" page in ASP.NET</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/03/12/88489.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/03/12/88489.aspx</id><published>2004-03-12T19:25:00Z</published><updated>2004-03-12T19:25:00Z</updated><content type="html">&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Many times we are faced with heavy or slow processing pages in our projects. If we cannot improve performance, how do we display some sort of information in the browser while the page is processing?&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;I used to have this problem when accessing slow databases or retrieving a large amount of information from it. Sometimes, the queries lasted for 30 seconds or even more and it's not very user-friendly to just sit there waiting. Many impatient users will often assume that the application has hanged and close the browser before the query results are shown.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Let's imagine the following scenario. We have a form where the user specifies some sort of search pattern. He then clicks a button and the results are shown in a datagrid in the same page. Ok, solving this is easy...you just add some client scripting to the button that triggers the round-trip to the database so that on the client side a message will be displayed (something like: please wait...loading the data).&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;But what if you want to show the results in another aspx? By this I mean you access a page and on the page_load you retrieve the data and populate the datagrid? What if you have a complex form with lots of drop down lists that must be populated and you want to show some sort of info to your users while they are waiting for the page to appear on the browser? And, what if you want to do something like a&amp;nbsp;dynamic bar to show that something is actually happening?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Well, I recently discovered a very useful method of the Response object. Because it functions like a Stream, you are able to say Flush several times during a request. What this means is that you don't have to wait for the entire page to be rendered to send the response down to the client. So, basically this looks like a good way of solving this problem: we&amp;nbsp;create a mixed blend of HTML and JavaScript in the beginning of the Page_Load event, we flush it to the client and we proceed with our server-side processing. When we get the data we don't have to do anything special. The Page_Load event will end and the HTML will be rendered by ASP&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:mswterms w:st="on"&gt;.NET&lt;/st1:mswterms&gt;. All we have to do is possibly hide the information we previously sent in order to display the page correctly.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;
&lt;P&gt;I encapsulated the entire logic into a single class (C#):&lt;/P&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt;&lt;FONT color=#000000&gt; System;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;using&lt;/FONT&gt;&lt;FONT color=#000000&gt; System.Web;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;namespace&lt;/FONT&gt;&lt;FONT color=#000000&gt; WaitPage&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;summary&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; To use this class, simply insert in the beggining of your page load the following line:&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; Wait.Send_Wait_Info(Response);&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; Also, in the HTML part of your web form add the following line at the end of the head section:&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;script&amp;gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;Stop_Wait();&lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;/summary&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; Wait&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; Wait()&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; MAIN_IMAGE = "images/logo.bmp";&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; PROGRESS_BAR_SIZE = 10; &lt;FONT color=#008000&gt;//number of steps in your progress bar&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; PROGRESS_BAR_STEP = "images/pro.bmp"; &lt;FONT color=#008000&gt;//image for idle steps&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;const&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; PROGRESS_BAR_ACTIVE_STEP = "images/pro2.bmp"; &lt;FONT color=#008000&gt;//image for active step &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; Send_Wait_Info(System.Web.HttpResponse Response)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Response.Write("&amp;lt;div id=\"mydiv\" align=\"center\"&amp;gt;");&lt;/P&gt;
&lt;P&gt;Response.Write("&amp;lt;img src=\"" + MAIN_IMAGE + "\"&amp;gt;");&lt;/P&gt;
&lt;P&gt;Response.Write("&amp;lt;div id=\"mydiv2\" align=\"center\"&amp;gt;");&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;for&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=1&gt; i=1;i&amp;lt;=PROGRESS_BAR_SIZE;i++)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("&amp;lt;img id='pro" + i.ToString() + "' src='" + PROGRESS_BAR_STEP + "'&amp;gt;&amp;amp;nbsp;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("&amp;lt;/div&amp;gt;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("&amp;lt;/div&amp;gt;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("&amp;lt;script language=javascript&amp;gt;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("var counter=1;var countermax = " + PROGRESS_BAR_SIZE + ";function ShowWait()");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("{ document.getElementById('pro' + counter).setAttribute(\"src\",\"" + PROGRESS_BAR_ACTIVE_STEP + "\"); if (counter == 1) document.getElementById('pro' + countermax).setAttribute(\"src\",\"" + PROGRESS_BAR_STEP + "\");else {var x=counter - 1; document.getElementById('pro' + x).setAttribute(\"src\",\"" + PROGRESS_BAR_STEP + "\");} counter++;if (counter &amp;gt; countermax) counter=1;}");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("function Start_Wait(){mydiv.style.visibility = \"visible\";window.setInterval(\"ShowWait()\",1000);}");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("function Stop_Wait(){ mydiv.style.visibility = \"hidden\";window.clearInterval();}");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Write("Start_Wait();&amp;lt;/script&amp;gt;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Response.Flush();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Verdana"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;This code will simply send some HTML and Javascript to the client creating an animated progress-like bar. You can download the source code of a demo app showing it's usage &lt;A href="http://vs.tkolegacy.org/samples/Wait.zip"&gt;here&lt;/A&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Verdana"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: Verdana"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;The Stop_Wait script block must be inserted in the end of the head section. When the final response is sent, the bar is cleared and the JavaScript cycle that animates the bar is stopped. Pretty simple &lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt;&lt;/v:path&gt;&lt;o:lock v:ext="edit" aspectratio="t"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Also, all the images presented can easily be changed. There are 4 constants defined in the class.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;The main image&lt;/FONT&gt;&lt;/SPAN&gt; 
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;The size of the bar (how many steps)&lt;/FONT&gt;&lt;/SPAN&gt; 
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;The image representing a step&lt;/FONT&gt;&lt;/SPAN&gt; 
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;The image representing the active step&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;so you can customize this at will. Also, I believe the code will help build your own mechanism. I just did it for the exercise so it's not very pretty :P &lt;/FONT&gt;&lt;v:shape id=_x0000_i1026 style="WIDTH: 11.55pt; HEIGHT: 11.55pt" alt="" type="#_x0000_t75"&gt;&lt;v:imagedata o:HREF="/nunos/content/binary/tongue.gif" src="file:///C:\DOCUME~1\nunos\LOCALS~1\Temp\msohtml1\01\clip_image002.gif"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Hope this proves of some use to you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=88489" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>Adding security patches to a new Windows XP installation</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/03/12/88478.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/03/12/88478.aspx</id><published>2004-03-12T18:33:00Z</published><updated>2004-03-12T18:33:00Z</updated><content type="html">&lt;DIV class=itemBodyStyle&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;It's common knowledge that you can integrate a service pack with the installation bits of Windows (a technique called splistreaming). However, the security update that prevents the Blaster worm is post SP1. Recently I've been asked to figure out a way to prevent 10.000 new XP workstations of infection. We were installing Windows XP SP1 in a network where the Blaster worm was running loose. Because the installation was made through the network using unnatended setup, we wanted to avoid all these machines to get infected during the installation itself. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;Well this didn't seem like an easy problem to solve. Tests were being made at the customer and the results were overwhelming. All workstations installed through this process were getting infected.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;The first thing that we tried was enabling ICF during the unnatended install. You can accomplish this by specifying the following keys in the unnatended.txt file:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;[Homenet] &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;InternetConnectionFirewall=Adapter1, [adapter2]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;where Adapter1, adapter2 are known references inserted in the [NetAdapters] section of the same file. Please look at ref.chm in the deploy.cab package included in the Windows XP CD.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;However, this approach did not work. ICF only gets enabled in the final boot so we would still get some infected machines. I assume they were getting infected soon after the network settings configuration.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;So, I started to worry and began working on a script to run on the first logon that would clean the workstation from the Blaster worm. However this approach was not the best either.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;Fortunately, I found out that in XP (and 2003) it is possible to integrate hotfixes during an unattended setup. This is documented in a KB article but I found out that it wasn't really common knowledge. Here you can find a link to the section of the article that covers this procedure:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/WindowsXP/pro/downloads/servicepacks/sp1/hfdeploy.asp#the_combination_installation_gxsi"&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#005bba size=1&gt;http://www.microsoft.com/WindowsXP/pro/downloads/servicepacks/sp1/hfdeploy.asp#the_combination_installation_gxsi&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;FONT face=Verdana size=1&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;Oh, and in case you're wondering...we tried it and it worked ;)&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=88478" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="Windows" scheme="http://blogs.msdn.com/nunos/archive/tags/Windows/default.aspx" /></entry><entry><title>Accessing an external CRL through a proxy</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/03/12/88473.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/03/12/88473.aspx</id><published>2004-03-12T18:28:00Z</published><updated>2004-03-12T18:28:00Z</updated><content type="html">&lt;DIV class=itemBodyStyle&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;One of the good ways to safely authenticate users in a web application is using client certificates.&amp;nbsp;When&amp;nbsp;accessing the web application, IIS will ask the client for a certificate installed&amp;nbsp;on the local machine, check if it's valid or not&amp;nbsp;and then allows you to read&amp;nbsp;the certificate and grant rights to the user.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;When checking the certificate, one of the steps performed is&amp;nbsp;accessing a CRL, or a&amp;nbsp;Certificate Revocation List, that contains all certificates issued by a particular entity that have been revoked. One thing that everyone must understand is that if the CRL cannot be reached, than the certificate will be assumed revoked for security reasons. In that case, IIS will return an HTTP error 403.13 (see &lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?id=294305"&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#005bba size=1&gt;http://support.microsoft.com/?id=294305&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;FONT face=Verdana size=1&gt;).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;In the problem we were facing none of the proposed solutions worked. If we opened a browser on the web server&amp;nbsp;and&amp;nbsp;tried accessing the CRL with it's URL&amp;nbsp;that would work. So, it had to do with proxy settings on the server.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;After some investigation I found the following KB articles:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=1&gt;819961 How to Configure Client Proxy Server Settings by Using a Registry File&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;A href="http://support.microsoft.com/?id=819961"&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#004183 size=1&gt;http://support.microsoft.com/?id=819961&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;&lt;FONT face=Verdana&gt;&lt;STRONG&gt;218970 Proxy Settings Can Be Set Only on a Per-User Basis&lt;/STRONG&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?id=218970"&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#005bba size=1&gt;http://support.microsoft.com/?id=218970&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;The first article tells us how to force proxy settings for users. Because proxy settings are set in a per-user basis these values will not be read when accessing the CRL because the Local System account is used to run the IIS Admin and the W3SVC services. That's why opening a browser and accessing the CRL works. In this case we are running in the context of a real user and using the proxy settings defined through IE. You can actually try to change the account running IIS Admin and W3SVC to a user account. This will work but at the end of the day you'll create a lot more problems and it is not a supported configuration.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;The second article tells us about a registry value called "ProxySettingsPerUser". If we force it to 0, we tell the machine to read proxy settings from HKLM instead of HKCU thus forcing a general proxy setting for all users (by the way, the article mentions an hotfix but in Windows 2000 it isn't needed).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;So, I tried adding the following registry information:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;&lt;FONT face=Verdana&gt;&lt;STRONG&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings] &lt;BR&gt;&lt;/STRONG&gt;"AutoConfigProxy"="wininet.dll" &lt;BR&gt;"ProxyEnable"=dword:00000001 &lt;BR&gt;"ProxyOverride"="&lt;LOCAL&gt;" &lt;BR&gt;"MigrateProxy"=dword:00000001 &lt;BR&gt;"ProxyServer"="x.x.x.x:8080" &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;&lt;FONT face=Verdana&gt;&lt;STRONG&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings] &lt;BR&gt;&lt;/STRONG&gt;"ProxySettingsPerUser"=dword:00000000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;And it worked. I must point out again that we do not fully support this configuration. If a web server needs to contact a CRL, there shouldn't be any proxy or firewall restricting its access. However, this workaround does work rather nicely :D&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;Hope it helps&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=1&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=88473" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="Windows" scheme="http://blogs.msdn.com/nunos/archive/tags/Windows/default.aspx" /><category term="IIS" scheme="http://blogs.msdn.com/nunos/archive/tags/IIS/default.aspx" /></entry><entry><title>Concerning the credentials double hop issue</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/nunos/archive/2004/03/12/88468.aspx" /><id>http://blogs.msdn.com/nunos/archive/2004/03/12/88468.aspx</id><published>2004-03-12T18:20:00Z</published><updated>2004-03-12T18:20:00Z</updated><content type="html">&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Being an ASP&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:mswterms w:st="on"&gt;.NET&lt;/st1:mswterms&gt; enthusiast, I've soon came across this issue and had to deal with it. This happened very shortly after the release of the &lt;st1:mswterms w:st="on"&gt;.NET&lt;/st1:mswterms&gt; Framework and, at the time, seemed like a major headache for developers. Well, actually it still does seem like a major headache but I've came to accept it as a "normal" thing :P.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Because I regularly post in ASP.NET newsgroups, I realized that every so often someone sends in an email stating that they lose the user credentials connecting to a &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; or accessing a file in a network share from within their ASP&lt;st1:mswterms w:st="on"&gt;.NET&lt;/st1:mswterms&gt; application. And this is called the "double hop" issue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;The typical scenario follows: you're building an intranet application and using Integrated Security. You're also setting "&amp;lt;identity impersonate="true" /&amp;gt;" in your web.config file. During an ASP&lt;st1:mswterms w:st="on"&gt;.NET&lt;/st1:mswterms&gt; request you can identify the current user but when accessing &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; in a trusted connection you&amp;nbsp;get a logon failure stating that user&amp;nbsp;Anonymous isn't allowed. So, basically, it seems that the credentials get lost somewhere in the middle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Let's look at it step-by-step:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Integrated Security - &amp;nbsp;What this means is that IIS doesn't explicitly ask the users for credentials. Instead the credentials used to log on to their workstation are used to authenticate against IIS. And here is the first hop: the user's credentials are passed from the workstation to the web server in a secure way.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Impersonate - This is a very cool feature. You can access resources in the context of the user currently using your application. This simplifies resource access control but it's only suited for resources hosted on the web server itself. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Double hop - For security reasons, NTLM credentials cannot hop between servers at will. So, accessing a &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; instance running on another machine other than the web server will result in a logon failure error. It would be the second hop: the web server would have to pass the user's credentials to the &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; machine. For security reasons this is not allowed. Imagine that you access a site through your browser, the site collects your credentials without your knowledge (Integrated security) and then starts doing whatever the developer desires with your identification. Clearly, this is not a good scenario.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Ok, and now that we identified the problem, how do we workaround it?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;There are a lot of possible ways to workaround this issue, but I actually couldn't find one that completely satisfies me. Oh well, security is a process and one that should be between our major concerns when writing an application. Here you'll find possible solutions to this problem. Note that you should carefully analyze each of these options and choose whichever fits your security and design requirements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; COLOR: #003300; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Basic Authentication (consider HTTPS in this case) &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; COLOR: #003300; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Kerberos and Trust&amp;nbsp;computer for delegation privilege in AD &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; COLOR: #003300; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Specify explicit credentials&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;1. When using basic authentication, users are asked to insert their credentials when accessing the site. In this case, they are authenticating against the web server and the machine can now use the credentials provided to access &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt;. You can think of this as the user giving permission to the machine to use his/her identification. This doesn't change anything in your code, it's only an IIS setting. Careful though, because the credentials are sent in clear text between the client machine and the web browser, so you should think of getting a SSL certificate and using https to secure communications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;2. It's a lot more complex to handle authentication this way but Kerberos would allow you to hop the user's identification between servers. You'll also have to give the web server the "Trust machine for delegation" privilege in AD. You'll need to ask a domain admin to do this and normally they don't really like to accept this type of request. It's not a question of bad attitude but concerns for security. If your domain admin refuses your request feel happy that he knows what he's doing ;)&amp;nbsp;Take a look here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;810572"&gt;&lt;STRONG&gt;&lt;FONT color=#005bba size=1&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;810572&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;3. This is the solution more commonly used. Basically, you do not connect to &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; using a trusted connection, you specify a username and a password in the connection string or you specify this values in the impersonation settings and still use a trusted connection. The connection is still secure, and the only problem you have is where to store the&amp;nbsp;these values&amp;nbsp;so that it'll be safe. Of course, you could hard-code it, but that would leave you with no easy way to change it afterwards. One way is to store it in web.config and that would give you an easy way to change&amp;nbsp;the parameters in runtime. Although the web.config file is not served by IIS (meaning that a client cannot view it in the browser) it's not the safest way to store this valuable piece of information. The recommendation is storing this values in the registry. This article although not specifically written for this issue, does show a way to accomplish this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;329290"&gt;&lt;STRONG&gt;&lt;FONT color=#005bba size=1&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;329290&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;That's about it. This is not meant to be a complete article on ASP&lt;st1:mswterms w:st="on"&gt;.NET&lt;/st1:mswterms&gt; security. It justs aims to give a few pointers on working around this common problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;FONT size=1&gt;Hope it helps.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=88468" width="1" height="1"&gt;</content><author><name>nunos</name><uri>http://blogs.msdn.com/members/nunos.aspx</uri></author><category term="ASP.NET" scheme="http://blogs.msdn.com/nunos/archive/tags/ASP.NET/default.aspx" /></entry></feed>