ASP.NET error: A namespace cannot directly contain members such as fields or methods
<p>I created a Web project in VS 2010 (selecting ASP.NET project) and I wrote following code</p>

<pre><code>&lt;% page language="c#" %&gt;

&lt;html&gt;

&lt;head&gt;
&lt;title&gt;Example 1: Hello World&lt;/title&gt;
&lt;/head&gt;

&lt;body bgcolor="white"&gt;

&lt;h1&gt;
&lt;%
string strUsersBrowser = "";
strUsersBrowser+=Request.Browser.Browser;
strUsersBrowser+=Request.Browser.MajorVersion.ToString();
strUsersBrowser+="."
strUsersBrowser+=Request.Browser.MinorVersion.ToString();
response.write("&lt;h1&gt;Your web browser is " + strUsersBrowser + "&lt;/h1&gt;")
%&gt;
&lt;/h1&gt;

&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>VS2010 returns an error :</p>

<p>Error : A namespace cannot directly contain members such as fields or methods</p>

<p>Also, I saved that file as "<strong>.aspx.cs</strong>" extension</p>

<p>Where is the problem ?</p>

<p>// I SOLVED IT...</p>
