I'm trying to add a web application in IIS under an existing (root level) website. The root level website's web.config file defines certain behaviorExtensions under system.serviceModel:
<extensions>
<behaviorExtensions>
<add name="errorHandler" type="API.ErrorHandler.WCFErrorHandlerElement, API.ErrorHandler, Version=1.5.1.832, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
The extension is used like this:
<serviceBehaviors>
<behavior name="DefaultRESTBasedHTTPSServiceBehavior">
<errorHandler />
</behavior>
</serviceBehaviors>
For certain reasons I'm not allowed to add a reference to the required assembly in the added website, so I want to disable the extension's inheritance by this way (in the added website's web.config of course):
<behaviors>
<serviceBehaviors>
<clear/>
</serviceBehaviors>
<endpointBehaviors>
<clear/>
</endpointBehaviors>
</behaviors>
I was also trying to prevent the inheritance of the extensions section like this: <extensions><clear/></extensions>. It seems though, that <clear/> is not supported for the extensions node.
Yet I get the following exception when a WCF error happens on the added website (the problem is at Line 191):
Parser Error Message: The type 'API.ErrorHandler.WCFErrorHandlerElement, API.ErrorHandler, Version=1.5.1.832, Culture=neutral, PublicKeyToken=null' registered for extension 'errorHandler' could not be loaded.
Line 189: <serviceBehaviors>
Line 190: <behavior name="DefaultRESTBasedHTTPSServiceBehavior">
Line 191: <errorHandler />
Line 192: </behavior>
Line 193: <behavior name="DefaultSOAPBasedHTTPSServiceBehavior">
Please consider, that it is not possible to prohibit inheritance in the root level website's web.config, because other added websites are using the settings in question.
If you are able to use the <location> element in the root web.config then you can chose which sections not to inherit using the inheritInChildApplications attribute:
For example:
<location path="MyWebApp" inheritInChildApplications="false">
<system.serviceModel>
</system.serviceModel>
</location>
Related
I'm trying to add the CORS headers to a WCF service which is part of a precompiled web site project in VS 2012.
The error
The type 'EnableCrossOriginResourceSharingBehavior, MyWebSite, Version=0.0.0.0, Culture=neutral' registered for extension 'crossOriginResourceSharingBehavior' could not be loaded.
from the config file
<behaviors>
<serviceBehaviors>...</serviceBehaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp />
<crossOriginResourceSharingBehavior /> <!-- Error Here -->
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="crossOriginResourceSharingBehavior" type="EnableCrossOriginResourceSharingBehavior, MyWebSite, Version=0.0.0.0, Culture=neutral" />
</behaviorExtensions>
</extensions>
Now, there is no MyWebSite.dll in a precompiled site, apparently. So, how do I get past this and make the BehaviorExtension work?
You have that error because the definition has a wrong type: you lost namescpace of the type.
<add name="crossOriginResourceSharingBehavior" type="MyWebSite.EnableCrossOriginResourceSharingBehavior, MyWebSite, Version=0.0.0.0, Culture=neutral" />
Probably the version is wrong, because it equals to 0.0.0.0 in the definition. See AssemblyInfo.cs for the assembly version.
I see the assembly hasn't a strong name. So you can remove Version and Culture from the definition.
<add name="crossOriginResourceSharingBehavior" type="MyWebSite.EnableCrossOriginResourceSharingBehavior, MyWebSite" />
i have a couple of web site in IIS now i have added a WCF service under sites>default website > MyWCFService.
When i tried to browse the Service1.svc file through content view in IIS i was presented below error
HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
Detailed Error Information
Module: StaticFileModule
Notification : ExecuteRequestHandler
Handler : StaticFile
Error Code 0x80070032
Requested URL : https://localhost:443/MyWCFService/Service1.svc
Physical Path : D:\Inetpub\wwwroot\MyWCFService\Service1.svc
Logon Method : Negotiate
Logon User : XXXXXXXXXXXXXX
Most likely causes:
•The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.
Things you can try:
•If you want to serve this content as a static file, add an explicit MIME map.
Here is my webconfig file:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyService.Service1" behaviorConfiguration="MyService.Service1Behavior">
<endpoint address="Service1" binding="basicHttpBinding" contract="MyService.IService1"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The service runs fine in my local machine, but it fails in IIS, may be something to do with IIS Settings?
I'm running on IIS version 7.5.7600.
Thanks in advance
Edit 1: : Installed WCF Activation (HTTP Activation and Non-HTTP Activation) under .net Framework 3.5.1 features in via Server mnager. Now the error when i tried browing the service1.svc file through browser is
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
i have added this entry in web.config file as well
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
No great change in output.
The requested content appears to be script and will not be served by the static file handler.
Don't use Content View, use a browser.
See also Script not served by static file handler on IIS7.5.
I have one test wcf service with default methods and web config is :
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
on local IIS it works fine when i publish it.But when i try to publish on remote IIS i am getting this error :
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS.
Line 23: </service>
Line 24: </services>
**Line 25: <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>**
Line 26: </system.serviceModel>
Line 27: <system.webServer>
thanks in advance.
I got the solution :
In IIS if the application is indeed an application, not a virtual directory? The icon should be something looks like the earth, not a folder's icon. If not, please convert it to an application right click on the folder select deploy and then Application.Service running with
Make sure you browse to the actual web folder (that contains Bin, *.svc and web.config) when creating web application, not the parent folder.
If you working framework 4.0 only one ENDpoint so write multipleSiteBindingsEnabled="False"
serviceHostingEnvironment multipleSiteBindingsEnabled="False"
Using this it will be run
I have searched online for a solution, but have yet to find one that works.
I have a Silverlight application that uses a WCF web service.
Everything runs fine on my development environment.
When I publish to my DiscountASP.NET account - the web service gives me the following exception:
"Server Error in '/eLearning/Services' Application.
The type 'eLearning.Web.Services.Learning, eLearning.Web', provided as the Service attribute value in the ServiceHost directive could not be found. "
Please refer to the actual exception at:
http://www.christophernotley.com/eLearning/Services/Learning.svc
I have made "eLearning" a web application - and moved the web.config to the root directory.
I have also confirmed that in the markup for the web service, that the service property states "eLearning.Web.Services.Learning, eLearning.Web".
Any ideas as to what I am doing wrong?
Thanks.
Chris
Here is the markup for the web service:
<%# ServiceHost Language="C#" Debug="true" Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="eLearning.Web.Services.Learning, eLearning.Web" CodeBehind="Learning.svc.cs" %>
Here is the System.ServiceModel web config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="RestBehaviorConfig">
<webHttp/>
</behavior>
<behavior name="webBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DebugEnabled">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.christophernotley.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="DebugEnabled" name="eLearning.Web.Services.Learning">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
Well, in a WCF scenario, your service URL is determined by three things:
the name of the server
the virtual directory (and any subdirectories) where the svc-file lives
the name and extension of the svc file itself
In your case, the URL is
http://www.christophernotley.com/eLearning/Services/Learning.svc
So this begs the question:
is /eLearning really defined as a virtual directory?
is there a /Services subdirectory below your virtual directory?
is the name of the *.svc file correct?
where is the actual service code located? Do you have an assembly with the service implementation, and is it located in a place that is accessible to the *.svc file? (it's directory, a .\bin subdirectory)? Or is the code in a App_Code directory? Where is this directory??
UPDATE:
I'm a bit confused about your setup..... you say /eLearning/Services is an application - a virtual application defined in IIS, right?
In your Learning.svc file, you define a code-behind file of Learning.svc.cs - so does your service code exist there? (because in another statement, you mention a .\bin directory under /eLearning - is your service compiled into an assembly that's deployed to that bin directory??)
Is there a way to serve up a custom "Sorry not found" page from a direct access request to a WCF Service (.svc file) on a server running IIS 6.0, and .NET 3.5 SP1.
I have a requirement that my service in a Production environment is not discoverable. The requirement states that WSDL publishing should be off, and the request also states that when directly accessing the MyService.svc file via a HTTP Get Request that a "Sorry Not found" page is displayed instead.
I have no problem disabling the metadata in the config file.
<serviceMetadata httpGetEnabled="false" />
But I can't figure out a way to not show the default .svc page.
SERVICE
This is a Windows© Communication Foundation service.
Metadata publishing for this service is currently disabled.
If you have access to the service, you can enable metadata publishing by completing the following steps to modify your web or application configuration file:
...
** Also posted at ServerFault.
in web.config:
<httpHandlers>
<remove verb="*" path="*.svc" />
<add path="*.svc" verb="POST" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false"/>
</httpHandlers>
Try setting http[s]HelpPageEnabled to false in Web.config. Example:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" />
<serviceDebug httpHelpPageEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>