简体   繁体   中英

Setting aspNetCompatibilityEnabled to true throws MethodAccessException in REST based JSON WCF Service

In my application's web.config. On, some servers if I set aspNetCompatibilityEnabled=true

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

I get "MethodAccessException". I need to use aspNetCompatibilityEnabled. Since, i want this call to be authenticated by one of ours HttpModule. I googled every where no answer found. It seems like there is an IIS setting that can fix it. Since, It is working in some internal environments.

Have you tried to put:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 

above your service class declaration?

如果您有多个WCFS服务而不是在所有服务中添加它

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM