how to write a simple server side script in aspx (c#)?
<p>I am a php developer and I am trying to convert some php scripts (repeat scripts) to aspx. I am trying to make a simple upload script, pure server side (with separated html). This script has to save the file in the server and stop. In this example I cant declare functions.This is my not working script and I do not know why:</p>

<pre><code>&lt;%@ LANGUAGE ='C#' %&gt;
&lt;%
        string filePath = Server.MapPath(Request.QueryString["ax-file-path"]);
        string fileName = Request.QueryString["ax-file-name"];

        string allowExtstr  = Request.QueryString["ax-allow-ext"];
        string[] allowExt   = allowExtstr.Split('|');


        if (!System.IO.File.Exists(filePath) &amp;&amp; filePath.Length &gt; 0)
        {
            System.IO.Directory.CreateDirectory(filePath);
        }

        if (!System.IO.File.Exists(thumbPath) &amp;&amp; thumbPath.Length &gt; 0)
        {
            System.IO.Directory.CreateDirectory(thumbPath);
        }

        if(Request.Files.Count&gt;0)
        {
            for (int i = 0; i &lt; Request.Files.Count; ++i)
            {
                HttpPostedFile file = Request.Files[i];
                if(file.FileName!="")
                {
                    string fullPath = checkFilename(file.FileName, allowExt, filePath);
                    file.SaveAs(fullPath);
                    Response.Write(@"{""name"":"""+System.IO.Path.GetFileName(fullPath)+@""",""size"":""0"",""status"":""uploaded"",""info"":""File/chunk uploaded""}");
                }
            }
        }


        public string checkFilename(string filename, string[] allowExt, string filePath)
        {   
            string[] windowsReserved    = new string[] {"CON", "PRN", "AUX", "NUL","COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
                                    "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};    
            string[] badWinChars        = new string[] {"&lt;", "&gt;", ":", @"\", "/", "|", "?", "*"};

            for (int i = 0; i &lt; badWinChars.Length; i++)
            {
                filename.Replace(badWinChars[i], "");        
            }
            string fileExt      = System.IO.Path.GetExtension(filename);
            string fileBase     = System.IO.Path.GetFileName(filename);

            //check if legal windows file name
            if(windowsReserved.Contains(fileBase))
            {
                Response.Write(@"{""name"":"""+fileBase+@""",""size"":""0"",""status"":""error"",""info"":""File name not allowed. Windows reserverd.""}");
                return "error";
            }

            //check if is allowed extension
            if(!allowExt.Contains(fileExt) &amp;&amp; allowExt.Length&gt;0)
            {
                Response.Write(@"{""name"":"""+fileBase+@""",""size"":""0"",""status"":""error"",""info"":""Extension "+fileExt+@" not allowed.""}");
                return "error";
            }

            string fullPath = filePath+fileBase;
            int c=0;
            while(System.IO.File.Exists(fullPath))
            {
                c++;
                fileBase= fileBase+"("+c+")."+fileExt;
                fullPath    = filePath+fileBase;
            }
            return fullPath;
        }
%&gt;
</code></pre>

<p>And simple html code :</p>

<pre><code>&lt;form action="upload.aspx" method=post enctype=......&gt;
&lt;input type=file /&gt;
&lt;/form&gt;
</code></pre>

<p>How should I write this code in correct way? </p>

<p><strong>EDIT:</strong> I just want some, help. If this is not a good form of writing aspx c#, just tell me how to do it not that I write poor aspx code. I am a c#, php developer and have no experice in aspx, that's why I am asking</p>
