title: Error Rendering Control - WebUserControl, An unhandled exception has occurred
body: <p>What can be wrong with my code? The visual studio doesn't get any warnings or error.</p>
  
  <p>ASP.NET, Error Rendering Control - WebUserControl, An unhandled exception has occurred.</p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"         Inherits="WebUserControl" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 
  
  &lt;script runat="server"&gt;
  
      protected void UploadButton_Click(object sender, EventArgs e)
      {
          // Specify the path on the server to
          // save the uploaded file to.
          String savePath = @"c:\temp\uploads\";
  
          // Before attempting to perform operations
          // on the file, verify that the FileUpload 
          // control contains a file.
          if (FileUpload1.HasFile)
          {
              // Get the name of the file to upload.
              String fileName = FileUpload1.FileName;
  
              // Append the name of the file to upload to the path.
              savePath += fileName;
  
  
              // Call the SaveAs method to save the 
              // uploaded file to the specified path.
              // This example does not perform all
              // the necessary error checking.               
              // If a file with the same name
              // already exists in the specified path,  
              // the uploaded file overwrites it.
              FileUpload1.SaveAs(savePath);
  
              // Notify the user of the name of the file
              // was saved under.
              UploadStatusLabel.Text = "Your file was saved as " + fileName;
          }
          else
          {
              // Notify the user that a file was not uploaded.
              UploadStatusLabel.Text = "You did not specify a file to upload.";
          }
  
      }
  
  &lt;/script&gt;
  
  &lt;html  &gt;
  &lt;head id="Head1" runat="server"&gt;
      &lt;title&gt;FileUpload Example&lt;/title&gt;
      &lt;style type="text/css"&gt;
          .style1
          {
              width: 100%;
          }
          .style2
          {
              height: 26px;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;table class="style1"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Select a file to upload:&lt;/td&gt;
              &lt;td&gt;
                  &amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="style2"&gt;
  
         &lt;asp:FileUpload id="FileUpload1"                 
             runat="server"&gt;
         &lt;/asp:FileUpload&gt;
  
              &lt;/td&gt;
              &lt;td class="style2"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
  
         &lt;asp:Button id="UploadButton" 
             Text="Upload file"
             OnClick="UploadButton_Click"
             runat="server"&gt;
         &lt;/asp:Button&gt;    
  
              &lt;/td&gt;
              &lt;td&gt;
                  &amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
  
         &lt;hr /&gt;
  
              &lt;/td&gt;
              &lt;td&gt;
                  &amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
  
         &lt;asp:Label id="UploadStatusLabel"
             runat="server"&gt;
         &lt;/asp:Label&gt;        
              &lt;/td&gt;
              &lt;td&gt;
                  &amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
      &lt;p&gt;
          &amp;nbsp;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Error message from web browser:</p>
  
  <pre><code>    Server Error in '/WebSite2' Application.
  --------------------------------------------------------------------------------
  
  You can only have one &lt;head runat="server"&gt; control on a page. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.Web.HttpException: You can only have one &lt;head runat="server"&gt; control on a page.
  
  Source Error: 
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
  
  Stack Trace: 
  
  
  [HttpException (0x80004005): You can only have one &lt;head runat="server"&gt; control on a page.]
     System.Web.UI.HtmlControls.HtmlHead.OnInit(EventArgs e) +1762795
     System.Web.UI.Control.InitRecursive(Control namingContainer) +333
     System.Web.UI.Control.InitRecursive(Control namingContainer) +210
     System.Web.UI.Control.InitRecursive(Control namingContainer) +210
     System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
     System.Web.UI.ControlCollection.Add(Control child) +80
     System.Web.UI.WebControls.WebParts.WebPartManagerControlCollection.AddWebPartHelper(WebPart webPart) +220
     System.Web.UI.WebControls.WebParts.WebPartManagerControlCollection.AddWebPartsFromZone(WebPartZoneBase zone, WebPartCollection webParts) +607
     System.Web.UI.WebControls.WebParts.WebPartManager.RegisterZone(WebZone zone) +240
     System.Web.UI.WebControls.WebParts.WebZone.OnInit(EventArgs e) +95
     System.Web.UI.WebControls.WebParts.WebPartZone.OnInit(EventArgs e) +9
     System.Web.UI.Control.InitRecursive(Control namingContainer) +333
     System.Web.UI.Control.InitRecursive(Control namingContainer) +210
     System.Web.UI.Control.InitRecursive(Control namingContainer) +210
     System.Web.UI.Control.InitRecursive(Control namingContainer) +210
     System.Web.UI.Control.InitRecursive(Control namingContainer) +210
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378
  </code></pre>