« Previous Next »

Thread: Check the APS.NET version of a website in IIS

Last post 02-25-2009 12:11 PM by skumar.vandanapu. 7 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (8 items)

Sort Posts:

  • 03-11-2008, 5:55 AM

    Check the APS.NET version of a website in IIS

    We are developing a tool (Windows application) to monitor certain configurations. One among them is to check the ASP.NET version of a website in IIS. So i need to get the ASP.NET version of our website programatically. Can any one please give me the right way to find out the ASP.NET version of my website.

     Note : IIS version is 6.0 or prior

    Thanks

    Sivakumar V

  • 03-12-2008, 4:17 PM In reply to

    • pgeorge
    • Not Ranked
    • Joined on 03-12-2008, 8:11 PM
    • Massachusetts
    • Posts 6

    Re: Check the APS.NET version of a website in IIS

    There's a command line tool aspnet_regiis.exe which can be used to register ASP.NET to a particular web site, but you can also aquire ASP.NET version information.

    Good Luck!

  • 03-18-2008, 7:18 AM In reply to

    Re: Check the APS.NET version of a website in IIS

    Hi george,

    Thanks for your help. it worked out for me.

     

  • 03-25-2008, 6:58 AM In reply to

    Re: Check the APS.NET version of a website in IIS

    Hi George,

    Do you have any idea to read relay restrictions under default smtp virtual server--> access-->relay--> Select which computer may relay through this virtual directory

    i have to read all the ip address under that using C#.net

  • 04-29-2008, 11:52 AM In reply to

    • crb
    • Not Ranked
    • Joined on 04-29-2008, 3:37 PM
    • Posts 6

    Re: Check the APS.NET version of a website in IIS

    Try something like this:

    /// <summary>
    /// Query if a directory is currently using a specific ASP.NET version.
    /// </summary>
    /// <param name="dir">Short name of the directory</param>
    /// <returns>Version number, in format vN.N.NNNNN</r>
    public static String QueryAspNetVersion(String dir) {

        DirectoryEntry dirEntry = null;
        String version = null;
        try {
        dirEntry = new DirectoryEntry(Combine("IIS://localhost/W3SVC/1/Root", dir));

        // get script map array
        object[] maps = (object[])dirEntry.InvokeGet("ScriptMaps");

        // iterate the object looking an .aspx script map
        for (int i = 0; i < maps.Length; i++) {
            String s = (String)maps[i];

            if (s.Contains(".aspx")) {
            // .aspx,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG
            version = Regex.Replace(s, @".*Framework\\(v\d.\d.\d+)\\.*", "$1");
            }
        }
        } catch (System.Runtime.InteropServices.COMException ex) {
        Console.WriteLine("Failed to query ASP.NET version: " + ex.ToString());
        } finally {
        dirEntry.Dispose();
        }
        return version;
    }

    You can parse the scriptmap to see what version of ASP.NET you're using.

    Regards
    Craig


  • 04-30-2008, 12:36 AM In reply to

    Re: Check the APS.NET version of a website in IIS

    Hi ,

    Thanks for your reply.

    In your code, you made use of a function called Combine. But it does not have defination. Can you please provide that function also.

  • 04-30-2008, 9:23 AM In reply to

    • crb
    • Not Ranked
    • Joined on 04-29-2008, 3:37 PM
    • Posts 6

    Re: Check the ASP.NET version of a website in IIS

    Combine just adds a subdirectory to a root path, and adds a / if there is not one already:

            /// <summary>
            /// Join a parent path and a child path in a metabase.
            /// </summary>
            /// <param name="parent">Parent path</param>
            /// <param name="child">Child node</param>
            /// <returns></returns>
            public static String Combine(String parent, String child) {
               
                string SEP = @"\";
                // trim off any separator on the child
                if (child.StartsWith(SEP)) {
                    child=child.Substring(1);
                }

                if (parent.EndsWith(SEP)) {
                    return parent + child;
                } else {
                    return parent + SEP + child;
                }
            }

    You could replace it with 

        dirEntry = new DirectoryEntry("IIS://localhost/W3SVC/1/Root/" + dir);

    Ensure also that the number of the web server is '1' - that is the Default Web Site (I took this example out of code where it is configurable).

    Craig

  • 02-25-2009, 12:11 PM In reply to

    case sensitive ROOT folder

    Can any one please answer,

    when root folder in w3svc/1/ROOT will be case sensitive like 'root' and 'ROOT'.

     

Page 1 of 1 (8 items)
Microsoft Communities