How to provide only Access for ELMAH.axd for Administrator login in web

后端 未结 1 1836
粉色の甜心
粉色の甜心 2021-01-05 05:17

I have created application and implemented ELMAH logging. In my site there are three types of users.

  • Admin : can everything (rights to view elamh.axd)
  • 1条回答
    •  暗喜
      暗喜 (楼主)
      2021-01-05 06:09

      If you're using Roles you can add this to your web.config:

      
          
              
                  
                  
              
          
      
      

      If you're not using roles you will have to specify each user you want to give access to:

      
          
              
                  
                  
              
          
      
      

      Update:

      As you aren't using any of the built in authentication/authorisation and you don't have control of the elmah page you're going to have to handle the BeginRequest() event:

      protected void Application_BeginRequest()
      {
          if(Request.Url.AbsolutePath.ToLowerInvariant().Contains("elmah.axd"))
          {
              // Check if user can see elmah and handle unauthorised users (return 401/redirect to login page/etc...)
          }
      }
      

      0 讨论(0)
    提交回复
    热议问题