我使用描述here的教程创建了一个MVC 3 WCF Rest项目。唯一的问题是,当应用程序以高信任级别运行时,能够运行项目并访问其余的api但是当我将信任级别更改为中级时,我访问服务时会得到以下内容
[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
System.Security.CodeAccessPermission.Demand() +46
System.ServiceModel.Description.ConfigLoader.CheckAccess(IConfigurationContextProviderInternal element) +12116253
System.ServiceModel.Description.ConfigLoader.LookupServiceBehaviors(String behaviorName, ContextInformation context) +12238226
System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +137
System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +67
System.ServiceModel.ServiceHostBase.ApplyConfiguration() +108
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +192
System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49
System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151
Microsoft.ApplicationServer.Http.HttpServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +63
Microsoft.ApplicationServer.Http.Activation.HttpConfigurableServiceHost..ctor(Type serviceType, IHttpHostConfigurationBuilder builder, Uri[] baseAddresses) +40
Microsoft.ApplicationServer.Http.Activation.HttpConfigurableServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +79
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +420
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615
请帮助..有关如何解决此问题的任何想法
答案 0 :(得分:0)
Web API项目目前无法部分信任。计划提供PT支持,但尚未实施。