Get IIS site name from for an ASP.NET website

后端 未结 6 1262
长发绾君心
长发绾君心 2021-02-02 05:59

In my ASP.NET web app I\'d like to look up the name it was given when it was created in IIS, which is unique to the server. I\'d not interested in the domain name for the web si

6条回答
  •  面向向阳花
    2021-02-02 06:24

    As @belugabob and @CarlosAg already mentioned I'd rather use System.Web.Hosting.HostingEnvironment.SiteName instead of System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName() because IApplicationHost.GetSiteName method is not intended to be called directly! (msdn)

    So you're better off using HostingEnvironment.SiteName property! (msdn)

    I think this should be the correct answer in respect to the documentation ;)

提交回复
热议问题