How to check in ASP.NET MVC View if site is running on localhost or 127.0.0.1

前端 未结 4 1971
离开以前
离开以前 2020-12-18 17:48

How to check in ASP.NET MVC View if site is running on localhost or 127.0.0.1?

相关标签:
4条回答
  • 2020-12-18 18:15

    You can use the HttpRequest.IsLocal Property

    0 讨论(0)
  • 2020-12-18 18:22
           <% if (Request.Url.DnsSafeHost.Contains("localhost") || Request.UserHostName.Contains("127.0.0.1"))
           {
    
           } %>
    
    0 讨论(0)
  • 2020-12-18 18:28

    for global.asax

    if (System.Diagnostics.Debugger.IsAttached){themeName = ConfigurationManager.AppSettings["ThemeName"];}
    
    0 讨论(0)
  • 2020-12-18 18:35
    @if (Request.IsLocal) { // do something }
    

    or

    <% if (Request.IsLocal) { // do something } %>
    
    0 讨论(0)
提交回复
热议问题