Url rewrite by global.asax and Error 404 in Asp.net
===

I am working on a project with following properties :

    Asp.net
    C# 
    .Net Framework 4
    IIS 7

and in it , I use the `Application_BeginRequest` to rewrite manually like this :

    void Application_BeginRequest(object sendet, EventArgs e)
        {
            
            bool IsUploading = System.Configuration.ConfigurationManager.AppSettings["IsUloading"] == "1";
    
            if (Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                return;
            }
    
            string Path = Request.RawUrl;
            string QueryString = "";
    
            if (Request.QueryString.Count != 0)
            {
                string[] u = Path.Split(new char[] { '?' });
                Path = u[0];
                QueryString = u[1];
            }
    
            string url = "";
    
            if (Path.EndsWith(".css") || Path.EndsWith(".js") || Path.EndsWith(".png") || Path.EndsWith(".jpg") || Path.EndsWith(".jpeg") || Path.EndsWith(".bmp") || Path.EndsWith(".htm") || Path.EndsWith(".png") || Path.EndsWith(".gif") || Path.EndsWith(".fla") || Path.EndsWith(".swf") || Path.EndsWith(".axd") || Path.EndsWith(".xml") || Path.EndsWith(".ashx"))
                return;
    
            if (!Path.EndsWith("/"))
                Path += "/";
    
            IEnumerator<string> Part = Path.Split(new char[] { '/' }).AsEnumerable<string>().GetEnumerator();
    
            if (Part.MoveNext() && Part.MoveNext())
            {
    
                if (Part.Current == "")
                    url = "Default.aspx";
    
                else if (Part.Current.ToLower() == "public")
                {
                    
                    if (Part.MoveNext() && Part.Current.ToLower() == "install")
                        url = "Public/Install.aspx";
                    else
                        url = "Public/PageNotFound.aspx";
                    
                }
                                      
                else
                    url = "Public/PageNotFound.aspx";
                
            }
            else
                url = "Public/PageNotFound.aspx";
    
            if (url.Contains("?"))
                Context.RewritePath("~/" + url + "&" + QueryString);
            else
                Context.RewritePath("~/" + url + "?" + QueryString);
            
        }



now when try to browse the page `localhost:97` , browser start to open the Default.aspx but if I try to open `localhost:97/Public/Install` the browser give me this error : 

    HTTP Error 404.0 - Not Found
    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Where is the error ?!!!

Sorry about my bad English , I an new. for more detail comment me

Regards

Ali Foroughi 