Error with WCF webservice moved to Azure VM - azure

I have an old WCF webservice that's been moved to Azure VM.
I can easily access in Azure:
https://wcf/service.svc,
but when I try to post to:
https://wcf/service.svc/json/DoAction
it comes back with an empty response, when I open this in the browser I get 404 error.
Outside of Azure it all works fine, any ideas what can I do to get it to work? I would like to keep it running in VM as there are other items that were moved and work fine.
Here is the part of the web.config file that relates to "/json/" part:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Service123" behaviorConfiguration="ChallengeBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="ChallengeMessageEncoding" contract="IService123" behaviorConfiguration="SoapServiceBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestServiceMessageEncoding" contract="IService123" behaviorConfiguration="RestServiceBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestServiceBehavior">
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
</behavior>
<behavior name="SoapServiceBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RestServiceMessageEncoding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="ChallengeMessageEncoding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>

There is no problem the code snippets seem to me. Which version IIS is installed in the Azure VM? Do you have enabled the feature supported for WCF in IIS.
I suspect that the WCF service published on the VM does not work properly. Try to publish a default WCF service application project and browse the self-introduction page.
In addition, for a specific port, you need to enable outbound/inbound permission on the firewall.
VM>>Settings>>Network
Feel free to contact me if there is anything I can help with.

#Abraham, thank you for your answer.
I finally got it working, not sure which part helped but changes I introduced included:
a) Installed additional WCF features (as above) as only 2 were installed
b) Added extra bits to web config (allowing to run URLs with dots in name /Foo.svc/Save )
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<clear />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
c) Another config to support dots:
<modules runAllManagedModulesForAllRequests="true" />
d) Extended endpoints to support HTTPS as the above started working for HTTP:
<service name="PrivateService" behaviorConfiguration="PrivateBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehavior" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehaviorSecure" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestSecure" contract="IPrivateServices" behaviorConfiguration="RestBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="Rest" contract="IPrivateService" behaviorConfiguration="RestBehavior" />
</service>
...
<webHttpBinding>
<binding name="Rest">
<security mode="None">
</security>
</binding>
<binding name="RestSecure">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>

Related

Getting 413 Payload too large then 500 System.ServiceModel.ServiceActivationException when i increase maxReceivedMessage in my WCF sharepoint app

I developed a wcf webservice in a sharepoint 2016 on premise environment.
When I try to upload a long body I used to get a 413 payload too large error so I changed my app.config to this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ilem.Sharepoint.WebServices.ISAPI.ilemGroupWS.Service">
<endpoint address="" binding="basicHttpBinding" contract="ilem.Sharepoint.WebServices.ISAPI.ilemGroupmWS.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ilem.Sharepoint.WebServices.ISAPI.ilemGroup/Service/" />
</baseAddresses>
</host>
</service>
</services>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name=""
helpEnabled="true"
automaticFormatSelectionEnabled="true"
maxReceivedMessageSize="2147000000"
/>
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<basicHttpBinding>
<binding name="MyBinding" maxBufferPoolSize="2000000000"
maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
<basicHttpsBinding>
<binding name="MyBinding" maxBufferPoolSize="2000000000"
maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpsBinding>
</bindings>
</system.serviceModel>
</configuration>
But now I get this error: 500 (System.ServiceModel.ServiceActivationException)
Is there any way to resolve this issue?
I found that behaviorConfiguration, bindingConfiguration, <security mode="Transport"> are not set in your code, please make sure to configure them.
You can try setting includeExceptionDetailInFaults to true or configuring tracing to get error details.

Multiple sites in Azure web app

My Azure web app (example.azurewebsites.net) has one custom domain, applicationhost.config:
<sites>
<site name="example" id="111111111">
<bindings>
<binding protocol="http" bindingInformation="*:80:customdomain.com" />
<binding protocol="https" bindingInformation="*:443:customdomain.com" />
<binding protocol="http" bindingInformation="*:80:example.azurewebsites.net" />
<binding protocol="https" bindingInformation="*:443:example.azurewebsites.net" />
</bindings>
<application path="/" applicationPool="example" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="D:\home\site\wwwroot" />
<virtualDirectory path="/iisnodedebugger" physicalPath="C:\DWASFiles\Sites\example\Temp\iisnode" />
</application>
<traceFailedRequestsLogging enabled="false" customActionsEnabled="true" directory="D:\home\LogFiles" />
<detailedErrorLogging enabled="true" directory="D:\home\LogFiles\DetailedErrors" />
<logFile logSiteId="false" />
</site>
...
</sites>
The custom domain's bindigs are automatically added to the default site (example).
I would like to change it, i would like to create a new site with bindings to the custom domain (customdomain.com).
applicationHost.xdt (created with IIS Manager):
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<sites>
<site name="example" xdt:Locator="Match(name)">
<bindings>
<binding bindingInformation="*:443:customdomain.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
<binding bindingInformation="*:80:customdomain.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
</bindings>
</site>
<site name="customdomain" id="222222222" xdt:Transform="InsertAfter(/configuration/system.applicationHost/sites/site[(#name='example')])">
<bindings>
<binding protocol="http" bindingInformation="*:80:customdomain.com" />
<binding protocol="https" bindingInformation="*:443:customdomain.com" />
</bindings>
<application path="/" applicationPool="example" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="D:\home\site\wwwroot2" />
<virtualDirectory path="/iisnodedebugger" physicalPath="C:\DWASFiles\Sites\example\Temp\iisnode" />
</application>
</site>
</sites>
</system.applicationHost>
</configuration>
After restart the transform is successfull.
The problem: it has no effect. The customdomain.com is still served from "D:\home\site\wwwroot" and not "D:\home\site\wwwroot2".
After that i deleted only the bindigs without adding the new site, customdomain still working... After that i deleted the whole site (example), example.azurewebsites.net and customdomain.com still working.
Where am I mistaken? Isn't it possible to manipulate the sites section?
May i ask why are you trying to make your life hard?
Why don't you deploy your 2nd application to a new Web App? You can share the same App Service Plan (same VM) if cost is the essence here.
Every Web App has its own custom domain settings which you can configure visually through the Portal:
https://azure.microsoft.com/en-gb/documentation/articles/web-sites-custom-domain-name/
i did this in the webconfig and it seems to work:
**<rule name="REDIRECT To Site Within a Site" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}"pattern="^www\.SiteWithinSiteName\.com$" />
<add input="{PATH_INFO}" pattern="^/path/SiteWithinSiteRoot/" negate="true" />
</conditions>
<action type="Rewrite" url="\path\SiteWithinSiteRoot\{R:0}" />
</rule>**

Problem with Basic Authentication on Windows Azure RDP

I have hosted one WCF Service on the Azure platform and in web.config enabled basic authentication as per below
<system.serviceModel>
<services>
<service behaviorConfiguration="SimpleServiceBehavior" name="RestService.RestServiceImpl">
<endpoint address="http://localhost/RestWCFDemo/RestServiceImpl.svc" binding="webHttpBinding" bindingConfiguration="secureBasic" contract="RestService.IRestServiceImpl" behaviorConfiguration="HttpEnableBehavior" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secureBasic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic"></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="HttpEnableBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
On Azure it is not running. In local I have hosted this service on IIS and Enabled basic authentication only then it will ask for credentials when I will access it from URL, same way I have disabled all authentication methods except basic still I can't run this service what could be the problem? Can anyone suggest a solution?
You can try adding a a proxyCredentialType to your transport:
<transport clientCredentialType="Basic" proxyCredentialType="Basic"/>
I would also set includeExceptionDetailInFaults="true" so you can see the problem better if that doesn't work.

ASP.NET MVC 2 & IIS : HTTP 500.24 favicon.ico Error

I have a little weird behavior with my ASP.NET MVC 2 application.
I'm using IIS 7.5, Windows Authentication and ASP.NET Impersonation for my webpage to load.
After several searches, I didn't found a nice way to get rid of the 500.24 Request that I keep getting on every page load (The favicon.ico at the root directory triggers this) :
I've looked at some articles like this one or that one but this doesn't seems to solve my issue. I need these settings on for my application to work here : .NET 4 Framework Integrated Mode pipeline, Windows Authentification and ASP.NET Impersonation.
Here's a simplified version of my web.config, if it can help anyone (of course, I've removed the connections strings for security reasons..)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<identity impersonate="true" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Windows">
<!-- roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" / -->
<!-- forms loginUrl="~/Account/LogOn" timeout="2880" / -->
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/Globe" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/Globe" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<security>
<requestFiltering>
<verbs>
<add verb="PUT" allowed="true" />
<add verb="DELETE" allowed="true" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
My application IS working, the favicon.ico IS loading, I'm just wondering why it does fires a 500.24 on every request (Of course, maybe it's Fiddler who can't authenticate itself and causes de 500.24 HTTP Error, but when it does normally it triggers a 401.2 - Unauthorized instead...)
My guess is that favicon.ico is either running in a different application pool, or there is a web.config in the root of the site that has issues.
So:
1) Check to see if the root of the site (the directory where /favicon.ico lives) includes a web.config. If it does, then check to see if it is setting a system.web/httpModule, or httpHandler, or system.web/identity (impersonate) or something like that, and the application pool is running in integrated mode.
So what you need to do is either remove the offending httpmodule/httphandler/impersonate setting, or change the application pool to run as classic, or add the same configuration your site includes which is <validation validateIntegratedModeConfiguration="false" />
What CarlosAg said. Cheap fix might be to move the favicon into the offended app rather than barking up the tree.
I did find the answer to my problem =)
You're gonna laugh at me, for sure.. =P
Well, part of the answer is the <validation validateIntegratedModeConfiguration="false" /> in the C:\inetpub\wwwroot that CarlosAg pointed out, but the other part was that I simply forgot to add the <link rel="icon" href="<%: Url.Content("~/favicon.ico")%>" type="image/x-icon" /> to my Site.Master file in my ASP.NET MVC 2 Application. Since Chrome and IE does look at the root directory for a favicon.ico, it appeared to work, but I didn't notice until now that Firefox wasn't loading up the favicon.
Now the favicon loads on every browser, and there is no 500.24 HTTP Request sent over in Fiddler.
Thanks ! =)

SharePoint, WCF and Anonymous Access

Does a WCF service on SharePoint require that Anonymous Access is enabled?
We have an application page which is calling the service using Ajax.Net, if Anon Access is off then we get prompted for the username and password, if it is on then all is well.
We are not using a WCF client, it is purely being called by the scriptmanager
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding
name="webHttpBinding_DataSources"
maxBufferSize="5242880"
maxReceivedMessageSize="5242880" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior
name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior
name="ServiceBehavior">
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="" />
<serviceDebug
includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"/>
<services>
<service
name="XXXXXXXX.DataSources.Services.DataSourceHelper"
behaviorConfiguration="ServiceBehavior">
<endpoint
address=""
behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding_DataSources"
contract="XXXXXXXX.DataSources.Services.IDataSourceHelper" />
</service>
</services>
</system.serviceModel>
</configuration>
Thanks, Phill
I managed to get it working with the following
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding
name="webHttpBinding_DataSources"
maxBufferSize="5242880"
maxReceivedMessageSize="5242880" >
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior
name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior
name="ServiceBehavior">
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="" />
<serviceDebug
includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"/>
<services>
<service
name="XXXXXXXXXX.DataSources.Services.DataSourceHelper"
behaviorConfiguration="ServiceBehavior">
<endpoint
address=""
behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding_DataSources"
contract="XXXXXXXXXX.DataSources.Services.IDataSourceHelper" />
</service>
</services>
</system.serviceModel>
</configuration>
I did an IISReset and had to close and re-open my browser to get it working though
Best Regards,
Phill

Resources