Solved

Simple WCF web service and yet I get the infamous "The webpage cannot be found"

Posted on 2014-12-17
14
230 Views
Last Modified: 2015-03-18
Hi Experts,

I need to create just a simple WCF web service.  I tried setting everything up using countless tutorials online and yet every time I go to "Right click on XXXX.svc -> View In Browser", I get the "The webpage cannot be found" message in IE.

Example tutorial that I followed to a T (other than naming): http://www.c-sharpcorner.com/UploadFile/013102/creating-wcf-service-iis-hosting-and-consuming/

Environment: Windows 8.1, VS2012, .NET 4.5, IIS 8.5,  IE 11

Service.svc:

<%@ ServiceHost Language="C#" Debug="true" Service="MyProject.Service"%>

Open in new window


Web Config:

<?xml version="1.0"?>
<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>
    <services>
      <service name="MyProject.Service">
        <endpoint address="" binding="wsHttpBinding" contract="MyProject.IService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

Open in new window


I have tried every suggestion that I can find online and nothing seems to make a difference.  I have tried 4 different tutorials (though they all tell me to do the exact same thing), and I always end up with the same exact issue.  Please help!!!!
0
Comment
Question by:axnst2
  • 8
  • 4
  • 2
14 Comments
 
LVL 11

Expert Comment

by:LordWabbit
ID: 40504409
Goto the debug menu, select exceptions and then select break on "Common Language Exception" and run it again, you might be actually getting a 500 internal server error.  Also check the title of your IE window, it may give more of an idea of what is wrong.
0
 

Author Comment

by:axnst2
ID: 40504626
Yeah, that made no difference:

WCF-Error.jpg
0
 

Author Comment

by:axnst2
ID: 40504856
Wabbit, it only takes 2 minutes to run through the tutorial I referenced above, are you able to reproduce the problem on your end?
0
 
LVL 10

Expert Comment

by:Walter Padrón
ID: 40505056
Open the IIS Manager console and verify that website exists and files are deployed correctly.
0
 

Author Comment

by:axnst2
ID: 40505091
Unfortunately yes:

WCF-Error-2.jpg
WCF-Error-3.jpgWCF-Error.jpg
0
 

Author Comment

by:axnst2
ID: 40505164
Any other ideas?  This definitely has something to do with the hosting end of things.  If I add a test app to the solution and ad a reference to the WCF library, I have no issues.  I only have issues if it's hosted in IIS
0
 

Author Comment

by:axnst2
ID: 40505197
When I tell it to discover, I see two things show up (Why???).  The ISS hosted one (bottom) gives an error, while the other works fine:

WCF-Error-4.jpg
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:axnst2
ID: 40505199
Details shows this:

There was an error downloading 'http://localhost/InvoiceImagePortal/Service.svc/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: 'http://localhost/InvoiceImagePortal/Service.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost/InvoiceImagePortal/Service.svc.  The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.

Open in new window

0
 

Author Comment

by:axnst2
ID: 40505273
The entire application works fine as long as it's not hosted in IIS
0
 
LVL 10

Expert Comment

by:Walter Padrón
ID: 40505857
The identity that is used for the application pool that hosts the WCF service must have full NTFS permissions on the %WINDIR%\temp folder.
0
 
LVL 10

Assisted Solution

by:Walter Padrón
Walter Padrón earned 333 total points
ID: 40505862
Also try to use basicHttpBinding
<endpoint address="" binding="basicHttpBinding" contract="MyProject.IService">

Open in new window

0
 
LVL 11

Assisted Solution

by:LordWabbit
LordWabbit earned 167 total points
ID: 40506355
Try running a repair of the .net integration with IIS, if you installed IIS first and then the .net framework (ie. visual studio) the correct .net handlers will not be in place.  To run a repair start a visual studio command prompt - from visual studio tools -> VS2012 x86 Native Tools Command Prompt, and type aspnet_regiis -i
0
 

Author Comment

by:axnst2
ID: 40506759
Walter, how do I check "The identity that is used for the application pool"
0
 
LVL 10

Accepted Solution

by:
Walter Padrón earned 333 total points
ID: 40507424
Open IIS Manager, click on Application Pools, then you see the Identity column

Try to run as LocalSystem (not recommended for security)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now