First to call application begin request to application to get first request.path for see global.asax file code

C#
<%@ Application Language="C#" %>

<script RunAt="server">

 void Application_BeginRequest(object sender, EventArgs e)
    {
        string curruntpath = Request.Path.ToLower();


        curruntpath = curruntpath.Trim();
        bool isredirected = curruntpath.EndsWith(".aspx");
        bool isredirected2 = curruntpath.EndsWith(".html");
        bool isredirected3 = curruntpath.EndsWith(".jpg");
        bool isredirected4 = curruntpath.EndsWith(".jpeg");
        bool isredirected5 = curruntpath.EndsWith(".gif");
        bool isredirected6 = curruntpath.EndsWith(".png");
        // string atr = curruntpath.Substring(curruntpath.IndexOf("/"));
        if (!isredirected && !isredirected2 && !isredirected3 && !isredirected4 && !isredirected5 && !isredirected6)
        
        {


            HttpContext obj = HttpContext.Current;
            string finalurl = curruntpath + ".aspx";


            if (System.IO.File.Exists(Server.MapPath(finalurl)))
            {
                
                obj.RewritePath(finalurl);
                
            }
            else
            {
                obj.RewritePath("Error.aspx");
            }


        }

        if (curruntpath.EndsWith(".aspx"))
        {

            HttpContext obj = HttpContext.Current;
            obj.RewritePath("Tohideextentions.aspx");
        }

    }


    void Application_Start(object sender, EventArgs e)
    {


    }

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
</script>