WCF Service IIS Hosting Error - wcf

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.

Related

WCF - Access Denied when creating folder

I've built a WCF service and want to host it on IIS. One of the features I want is to programmatically create a subfolder in the WCF webhost root, to persist some json files.I've tested it on my local dev IIS Express and it works fine, which is no surprise 'cause I have all the necessary permissions.Now, I want to publish it on my public domain. For this, I've created a subdomain on Plesk and a subfolder within httpdocs. I've copied the web.config file and the Bin folder from my dev machine to this folder on my domain. But, when I enter the svc url on my browser I get a access denied exception (the folder is created in a dependency injected in my service, that's why I get the exception at this point).
Server Error in '/' Application.
Access to the path
'C:\Inetpub\vhosts\««my domain»»\httpdocs\VersioningService\Repository' is
denied.
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.UnauthorizedAccessException: Access to the
path
'C:\Inetpub\vhosts\««my domain»»\httpdocs\VersioningService\Repository' is
denied.
Below is my web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add factory="VersioningService.Services.ManualMajorMinorVersioningHostFactory"
relativeAddress="~/ManualMajorMinorVersioning.svc"
service="VersioningService.Services.ManualMajorMinorVersioning" />
</serviceActivations>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This is what I use to get the current assembly path:
var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
Note: If I use the ProgramData folder I get NO exception, but I would prefer to have a subfolder within the WCF folder.
This is clearly a permissions issue. Do I need to add something else to my web.config?Do I need to ask my host provider to give some extra permissions to some user?

WCF Activation for MSMQ where the service (.svc) is on the root

VS 2012/.NET4.5, Windows 8/IIS8 and 64 bit
Using WCF Service application, all the documentation that I've seen so far in naming my MSMQ queue to match the service name assume the fact that I am using an application or a virtual directory underneath the IIS website.
This is quoted from MSDN http://msdn.microsoft.com/en-us/library/ms789042.aspx
The application being activated must match (longest match) the prefix
of the queue name.
For example, a queue name is:
msmqWebHost/orderProcessing/service.svc. If Application 1 has a
virtual directory /msmqWebHost/orderProcessing with a service.svc
under it, and Application 2 has a virtual directory /msmqWebHost with
an orderProcessing.svc under it, Application 1 is activated. If
Application 1 is deleted, Application 2 is activated.
Also, http://blogs.msdn.com/b/tomholl/archive/2008/07/12/msmq-wcf-and-iis-getting-them-to-play-nice-part-1.aspx
However when you are hosting your MSMQ-enabled service in IIS 7 WAS,
the queue name must match the URI of your service's .svc file. In this
example we'll be hosting the service in an application called
MsmqService with an .svc file called MsmqService.svc, so the queue
must be called MsmqService/MsmqService.svc. Queues used for WCF
services should always be private
And, http://msdn.microsoft.com/en-us/magazine/cc163357.aspx
It's important to note that the activation of MSMQ endpoints only
works correctly if the queue has the same name as the .svc file (minus
the machine name). That means that if your service endpoint is
/server/app/service.svc, the queue name must be app/service.svc.
MyService.svc file is directly under the root of my IIS website (which is using a .NET 4 pool in integrated mode), so I did the following:
Creating a private transactional queue called MyService.svc and giving Network Services full control (for testing).
Setting my web.config endpoint: address="net.msmq://localhost/private/MyService.svc"
I was able to push a message to the queue using a client test application using the address in (2).
I added MSMQ protocol support to the website by executing the following:
C:\Windows\System32\inetsrv>appcmd set site "MyWebsite" /+bindings.[protocol='net.msmq',bindingInformation='localhost'] (and checked that it added the support properly)
From my website advanced settings I have http,net.tcp,net.msmq In Enabled Protocols
I double checked that "Net.Msmq Listener Adapter", which is responsible for activating the service when a message arrives, is running and I restarted it.
My web.config:
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
<add binding="netMsmqBinding" scheme="net.msmq" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
multipleSiteBindingsEnabled="true" />
<bindings>
<netMsmqBinding>
<binding name="MsmqBinding_IMyService" exactlyOnce="true"
receiveErrorHandling="Move">
<security mode="None"/>
</binding>
</netMsmqBinding>
</bindings>
<services>
<service name="CompanyName.Service.MyService">
<endpoint name="MyService"
address="net.msmq://localhost/private/MyService.svc"
bindingConfiguration="MsmqBinding_IMyService"
binding="netMsmqBinding" contract="IMyService" >
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
My service is not getting activated with the arrival of new messages to the queue and the messages stay in the queue. Is that because I am not using an application or a virtual directory or is there something I am missing?
The problem is sorted by creating an application within the default website and modifying the configuration to fit the new path.

Seeting the default page of the svc-less WCF service

I made a 'Hello World' WCF service. The service doesn't have a svc file.
Therefore the web.config file determines its address and other settings.
However, I'm stuck with opening the specific page.
When I run the WCF service project, it always shows the error page (HTTP Error 403.14).
This is because the browser tries to go to localhost instead of localhost/HelloWorldService.svc.
Do you know how can I solve it?
I want to open the localhost/HelloWorldService.svc when I start running the WCF service in VS 2012.
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
<a href="http://go.microsoft.com/fwlink/?LinkId=169433">http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment >
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="HelloWorldService.svc"
service="HelloWorldService.HelloWorldService"/>
</serviceActivations>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Go to Properties -> Web -> click Specific Page and enter /HelloWorldService.svc.

WCF Exception on Hosted Server

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??)

How can you hide the fact your server has a WCF service located at MyService.svc

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>