title: C# Insert block of code to every aspx page
body: <p>I'm having a web application project which is running .NET 4.0. I've plenty of .aspx page and now I would like to add in a block of script code to all the .aspx page header, for example Google Analytics.</p>
  
  <p>I know there is a solution to do is add in every single page, but I would like to know is there any other's way to do this instead modify every single .aspx page?</p>
  
  <p>*My header is not runat server</p>
  
  <p>I got an idea to do but not sure it's work or not.</p>
  
  <ul>
  <li>Get the page class in Global.asax</li>
  <li>Get the output stream from the page class.</li>
  <li>Insert the Google Analytics code in the HTML header.</li>
  </ul>
  
  <p>I couldn't get the Page.Response in the Global.asax as I tried in the Application_PostRequestHandlerExecute &amp; also Application_EndRequest. Does anyone know is this work and how it's work?</p>
  
  <p>Thanks.</p>