10

3 개의 ASP.net MVC 웹 응용 프로그램을 작성했으며 모두 ISP의 공유 호스팅 서버에 배포됩니다.log4net ASP.Net MVC 웹 응용 프로그램의 보안 예외가 발생했습니다.

3 가지 응용 프로그램 모두 구성 및 설정이 매우 유사합니다. 첫 번째 응용 프로그램은 2, 3 번째 서버와 다른 서버에 배포됩니다. 첫 번째 응용 프로그램에서 오류가 발생하지 않습니다. 무작위 :

2 층과 3 응용 프로그램은 다소 다음 에 SecurityException을 뱉어

alt text http://i46.tinypic.com/24p9pac.jpg

Link

예외 텍스트 :

Security Exception 
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 

[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.] 
    System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0 
    System.Security.CodeAccessPermission.Demand() +58 
    System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +99 


Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082 

web.config를 배치하거나 편집 한 후 위의 오류가 발생했습니다. 그러나 후속 페이지를 다시로드 할 때 얻지 못합니다. 2 개의 웹 사이트는 하루 중 나머지 시간 동안 다시 정상이 될 것이지만 다음 날 아침 나는 같은 오류가 다시 발생합니다.

재 컴파일을 강제하는 것으로 가정하는 web.config를 편집 한 후에도 오류가 계속 나타 납니까?

도와주세요. 문제가 뭔지 잘 모르겠습니다. IIS의 보안 설정과 관련이있는 것 같습니다. 오류를주지 않는 첫 번째 웹 응용 프로그램이 완전히 다른 서버에 있다는 점을 제외하고는 세 가지 웹 응용 프로그램이 모두 비슷한 방식으로 설정 및 배포됩니다.

답변

20

은 그래서 위의 SecurityException가에 대한 이유는 내 ISP는 ASP.net이 매체 신뢰는 새로운 서버의에 모드, 완전 신뢰로 실행되도록 구성한 3 배

  • 것을 밝혀 모드로 설정합니다. 내 웹 응용 프로그램 나는 그들이 내가 오류 로깅에 log4net을 사용하고 정확하게 같은

  • 를 구성에도 응용 프로그램 사이에서 다른 동작을 받고, 내 Global.asax에에있는 이유 인이 두 서버간에 분할 - log4net.Config.XmlConfigurator.Configure(); 위의 예외를 던지고 것입니다

    protected void Application_Start() 
    { 
        RegisterRoutes(RouteTable.Routes); 
        log4net.Config.XmlConfigurator.Configure(); 
        log.Debug("Logging Initialized."); 
    } 
    

    이 줄 : 파일, 나는 다음 있습니다. 응용 프로그램이 시작될 때 한 번만 발생하거나 web.config이 수정되면 다시 시작됩니다. 그래서 문제가 어디에서 왔는지 파악할 수 없었습니다.

  • 내가 의 Web.config에서 log4net의 configSection에requirePermission = "false"로 추가했다 : 나는 중간 신뢰 모드에서 개발 한 경우 지금

    <section name="log4net" requirePermission="false" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> 
    

, I 이 문제들을 고르면된다. 내 웹에 다음을 추가하여 앱을 중간 신뢰 모드로 강제 실행할 수 있습니다.설정 : 중간 신뢰 모드에서 실행하도록 내 응용 프로그램을 강제로

<system.web> 
    <trust level="Medium"/> 
    </system.web> 

, 나는을 위해 ..

+3

우수한 끝이 발생한 위치를 정확히 디바이스의 소스 예외를 포착, 거기부터 잘못 알아 냈어 신뢰 수준을 보통으로 설정하면 로컬 컴퓨터에서 디버그 할 수 있습니다. 감사! – Adventure

관련 문제