2012-08-15 2 views
6

IIS 7에서는 Nancy 프로젝트를 사용하여 웹 사이트를 만들었습니다. 그런 다음 별칭 api을 사용하여 사이트에 MVC 2 응용 프로그램을 추가했습니다. Nancy 프로젝트에서 정의 된 경로를 완벽하게 방문 할 수 있습니다. 내가 /api를 방문 할 때 그러나, 나는 다음과 같은 오류가 발생합니다 :IIS 7의 Nancy 사이트에 MVC 2 응용 프로그램 추가

Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'. 

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: 

[HttpException (0x80004005): Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'.] 
    System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +11588073 
    System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +47 
    System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +18 
    System.Web.Configuration.HandlerFactoryCache..ctor(String type) +27 
    System.Web.HttpApplication.GetFactory(String type) +95 
    System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +352 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375 

MVC 2 응용 프로그램이 요청을 처리하기 위해 NancyHttpRequestHandler를 사용하려고하는 것 같다. Nancy 응용 프로그램에 정의되지 않은 경로는 404 페이지를 표시하기 때문에이를 말합니다.

내가 시도 몇 가지 다음 MVC 2 응용 프로그램의 Web.config으로

  1. , 나는이 (가) <system.web/> 블록에 다음과 같은 추가 : 낸시 응용 프로그램의 Web.config

    <httpHandlers> 
        <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </httpHandlers> 
    
  2. 을, 나는 추가 <system.web/> 블록에 대한 다음 내용 :

    <httpHandlers> 
        <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> 
        <remove verb="*" path="api/*" /> 
    </httpHandlers> 
    
  3. 두 응용 프로그램에서 모두 <system.webServer/><system.serviceModel/> 블록의 설정을 사용해 보았습니다.

MVC 2 응용 프로그램이 IIS 7의 Nancy 사이트에 포함될 때 제대로 작동하도록하려면 어떻게해야합니까? 모든 지침은 크게 감사하겠습니다.

답변

1

당신은 적절한 생각을했습니다. NancyFx 특정 구성 섹션의 하위 MVC 사이트에 대한 상속을 차단해야합니다.

루트 (NancyFx) 사이트에서 정상 구성으로 <location/> 태그를 생성하십시오. NancyFx web.config 구조는 다음과 같습니다. MVC2 사이트를 MVC3으로 업그레이드하기로 결정한 경우 문제를 해결하기 위해 의견을 추가했습니다.

<configuration> 
    <configSections/> 
    <!-- FYI... configSections cannot be moved into the location tag. If you plan 
     to upgrade to MVC3 and use the Razor view engine, those configSection 
     declarations need to live here. If you upgrade to MVC3 and use the Razor 
     view engine, you will need to remove the Razor configSections from the 
     views/web.config files any child MVC3 project. --> 
    <system.web /> <!-- site-wide system.web settings --> 
    <system.webServer /> <!-- site-wide system.webServer settings --> 

    <!-- Put the NancyFx specific configuration here --> 
    <location path="." inheritInChildApplications="false"> 
    <!-- The inheritInChildApplications attribute is the magic sauce! :) --> 
    <connectionStrings /> 
    <!-- If the connectionStrings are shared by the child site, 
     you could move them out to the main configuration. But they 
     cannot exist in both sections of this file. --> 
    <appSettings /> 
    <system.web> 
     <httpHandlers> 
     <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> 
     </httpHandlers> 
    </system.web> 
    <system.webServer> 
     <handlers> 
     <add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> 
     </handlers> 
    </system.webServer> 
    </location> 
</configuration> 
+0

우수! 그냥 이것을 테스트하고 그것은 매력처럼 작동합니다. MVC3 작업을 지난 2 주간 낸시 (Nancy) 팀으로 이관하도록 설득 할 수만 있다면. :) 정보 주셔서 감사합니다. 건배! –

관련 문제