Basic WCF service gets "Invalid application path" on Test Settings - wcf

Caveats: It's been six years since I deployed a few web services and my knowledge of IIS is slim.
Background: I'm trying to host a WCF 4.0 service under IIS on my local box (Win7 64-bit) but keep getting "Invalid application path" when attempting to Test Connection. So I've gone vanilla and
created and started a new WCF Application (via the .NET template) (so responds under Cassini);
added a new application under the Default Web Site;
assinged it to the DefaultAppPool;
set the path to the folder where my .svc file resides; and
verified that the DefaultAppPool is targeting the 4.0 framework
Also, when I test the default web site settings pass-through authentication succeeds but an Authorization warning indicates "Cannot verify access to path (C:\inetpub\wwwroot).
Problem: When I pull up the apps basic settings and click "Test Settings..." I get an error "There was an error while performing this operation. Details: Invalid application path"
Does anyone have suggestions as to how to get the settings to check out correctly?
Thanks.

Related

Can I run .Net 4.6 Application under .Net Core Site on IIS

I inherited a project that is a collection of WCF Services that target .Net Framework 4.6.1. I wrote a front end SPA application that targets .Net Core 2.2 not realizing that the hosting model was such that both the UI (.Net Core) and the API (.Net 4.6.1) need to run under one Site on IIS.
I'm trying to get this to work on my local machine. I created a new Site in IIS -- Site A. I published my .Net Core application to Site A and set it up with an application pool set to "No Manged Code".
I then added an Application to Site A called API and added all my WCF services in that folder. I configured API to use an application pool that targets ".NET CLR 4.0".
I updated the web.config in the root of Site A to include all the necessary bits for WCF.
I'm able to hit Site A and get my SPA UI, but when I do anything that attempts to hit the backend API (including trying to hit it directly -- http://localhost:464646/api/test.svc), I get the following error:
HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure
Is what I'm doing even possible? If so, what changes do I need to make in order to get this to work?

Get HTTP 500 error hosting ASP.Net Core MVC app in IIS

I am new to ASP.Net Core and trying to host my first simple MVC app in IIS. I have installed the IIS hosting bundle; published my MVC project to a folder using Visual Studio and then, created an IIS website with it's physical path set to the published folder. When I test it using url http://localhost:5008/home/CallApi, however, I am getting a 500 error that says "This page isn’t working. localhost is currently unable to handle this request.". I can run the MVC app from within VS (selfhost, not through IIS, on a different port), it works fine there. What am I doing wrong here?
If you want to deploy ASP.Net Core MVC applications to IIS, you need to install the .NET Core host bundle, otherwise "500 Error" will appear. If you successfully install the .NET Core host bundle, you can find AspNetCoreModuleV2 in Modules:
Download the installer using the following link:
https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-3.1.9-windows-hosting-bundle-installer
After adding the site, you need set the .NET CLR version to No Managed Code:
For more information about using IIS to host ASP.NET Core on Windows, you can refer to this link:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1
UPDATE:
I suggest you enable viewing of PII logs so that we can view more detailed information about the error:
public void ConfigureServices(IServiceCollection services)
{
IdentityModelEventSource.ShowPII = true;
....
You can refer to this link, which contains similar questions:
"InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII is hidden]'"
For those with the same issue, I found that no setup guide I found mentions what was, for me, a required step:
Open IIS Manager
Navigate to [Server]\Sites[Your site]. A folder is listed for your .NET application, but the icon shows as an ordinary folder, as if in Windows Explorer.
Right-click the folder and select, "Convert to Application".

NetCore API Impersonate

I have a Web and an API NetCore Application running in a machine that I have access by VPN.
There, in IIS, I've configured both applications in IIS: The Web and the API. They are running well.
At the API, I've tryied to open the file from a network path:
\10.50.20.24\g$\Buffer\821003\003\22\34\821003003223428.WAV
In my code, when I try to verify if the file exists, using System.IO.File, to after move it, I received a message saying that the file doesn't exists.
"file was not found"
But the file exists, and the file is there when I try to access it from Windows Explorer.
In the IIS, I've configured the same user to run the application, in the Identity of the application pool.
I've tried lots of things to try to access the file, unsuccessfully.
Do you think this is related to Impersonation? How could I implement Impersonation in Asp.Net Core API 3.1 ?

.NET Standard: Microsoft WCF Web Service Reference Provider does not ask for credentials

In a c# console application, whenever I clicked Add > Service Reference and inserted a WCF URI, and I would be prompted to type my credentials:
When I try to do the same thing now in a .NET Standard solution (and after upgrading my Visual Studio to v15.5.6), I click Add > Connected Service > Microsoft WCF Web Service Reference Provider, I input the URI but I do not get the prompt for credentials, I simply get error 502 Bad Gateway!
Does anyone know how to get the Connected Service to ask for my credentials?
PS: I tried adding the username/password in plain text in the URI (using username:password# syntax) but still no luck.
As an alternative can you not use the browse button to point to the .wsdl file in the Local disk.
That way you are guaranteed your reference is pointing to the correct path.

Referencing a Published WCF Service

I have followed "Walkthrough: Creating and Accessing WCF Services" from http://msdn.microsoft.com/en-us/library/bb386386.aspx to create a WCF Service Library. I tested it in WCF Test Client. Then in another desktop application (let's call it A) that eventually I would like to use this WCF I added the Service Reference that WCF Test Client gives
http://localhost:8733/...
and that worked too.
Now, I am in the process of publishing and using the published version's service reference. Here is what I did, I published the WCF Service Library by
right-clicking the solution
Choosing Publish
clicking ...
Choosing File System and typing
\mywebaddress.example.com\wwwroot\myWCFService
Looks like the publish is successful, because by navigating to
\\mywebaddress.example.com\wwwroot\myWCFService
in a file browser, I see that Web.config, .svc and bin folder are created.
Now, I am trying to refer to this published version from my desktop application A. I am not certain what options I'm supposed to choose
Here is what I have tried:
Choose Add Service Reference in the desktop application A,
I tried
\mywebaddress.example.com\wwwroot\myWCFService
in the Address field of Add Service Reference, Pressed Go and received the error An error (Details) occurred while attempting to find services at
\\mywebaddress.example.com\wwwroot\myWCFService.
When clicking on Details, I get There was an error downloading
\\mywebaddress.example.com\wwwroot\myWCFService
Access to the path
\\mywebaddress.example.com\wwwroot\myWCFService
is denied.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Alternatively, I tried Advanced option from Add Service Reference and from there Add Web Reference... and in the URL field typed
http://www.example.com/myWCFService/
then when pressing the arrow button I get 401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied. and in the Web services found at this URL: Value cannot be null. Parameter name: discoveryError & mexError.
Th latter error was when in the IIS setting I had Anonymous Authentication Disabled. After enabling Anonymous Authentication the error becomes:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
Web services found at this URL: There was an error downloading
http://www.example.com/wcfservice/_vti_bin/ListData.svc/$metadata
The request failed with HTTP status 404: Not Found.
When I just now published a WCF Service Library project with Visual Studio 2013, I was offered the options for file system, Local IIS, and FTP Site. When I choose "Local IIS", it shows me both IIS Express and my local full IIS.
I just published to IIS by selecting "Default Web Site" and clicking the "Create Web Application" button in the tooolbar. I named the application, clicked "Open", then clicked "Publish" on the main publish dialog.
This published a bin folder with the service DLL and other libraries it needed, a web.config, and a .svc file. I was able to browse to the .svc file with no problem. I was even able to add it as a service reference to another project.
If you are always going to host your services in IIS, and if you don't need to keep a clean separation of layers (perhaps you're only writing a few, simple services), then I recommend you use the "WCF Service Application" template instead. This creates a Web project in which to host the services, as well as the .svc and .cs files necessary for the services themselves. That's more like the only option that was available for ASMX web services.