Hosting WCF service on IIS7.5, receiving 404.0 error - c#

I just received a new development laptop and now I can't get one of my WCF services running on the new laptop.
Windows 7 Enterprise
IIS 7.5.7600.16385
Windows Features Installed:
Internet Information Services
Web Management Tools
IIS 6 Management Compatibility
IIS Management Console
IIS Management Scripts and Tools
IIS Management Service
World Wide Web Services
Application Development Features (all sub-features)
Common HTTP Features
Default Document
Directory Browsing
HTTP Errors
HTTP Redirection
Static Content (all sub-features)
Health and Diagnostics (all sub-features)
Performance Features (all sub-features)
Security (all sub-features)
Internet Information Services Hostable Web Core
Microsoft .NET Framework 3.5.1 (all sub-features)
Windows Process Activation Service (all sub-features)
I dropped a simple "Hello World!" index.html file at the root of the WCF services application. I am able to serve that .html file. My services are under a sub-directory named "Hosts". I also dropped a simple index.html file under that sub-directory - I am able to serve that file as well. I cannot serve any of my .svc files though.
http://localhost/mywcfapplication/Hosts/IncidentService.svc
Anonymous Authentication -- "Application pool identity" is selected
The services are running in their own application pool. About the app pool:
.NET Framework Version: v2.0
Enable 32-bit applications: false
Managed Pipeline Mode: Classic
Identity: ApplicationPoolIdentity
I recently set these services up on a new Windows Server 2012 R2 web server in our test environment (old test server was decommissioned). On the server I had to give the app pool user permission to the directory in the file system (IIS_IUSRS\apppoolname), but my laptop doesn't seem to like this.
I'm receiving a 404.0 error when I attempt to browse to any of my .svc files under this application. IIS tells me the most likely causes are: •The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
I have checked and re-checked the URL, and I can serve the .html files. I verified that the .svc files do exist. I'm at a loss. What have I overlooked?
Research:
IIS7.5 WCF Service - HTTP Error 401.3 (Even after adding IIS_IUSRS)
Hosting WCF service on IIS7.5
Windows 7 IIS7.5 and asp application Error HTTP 404.0 - Not Found
UPDATES:
6/8/15 - I added IIS AppPool\AppPoolName to the IIS_IUSRS group. No change.
6/9/15 -
I ran servicemodelreg -i. No change.
https://msdn.microsoft.com/en-us/library/ms752252(v=vs.90).aspx
Because I'm getting desperate, I ran aspnet_regiis –i –enable and then "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
I also followed the steps listed "to verify that the svc file type is mapped correctly in IIS7.0"
HTTP 404 when accessing .svc file in IIS -- "We had a similar problem, and the SVC handler was already correctly installed. Our problem was the ExtensionlessUrl handler processing requests before they reached the SVC handler. To check this - in Handler Mappings in IIS Manager at the web server level, view the list of handlers in order (it's an option on the right-hand side). If the various ExtensionlessUrl handlers appear above the SVC handlers, then repeatedly move them down until they're at the bottom."
I verified that the extensionless handlers were at the bottom.
At the advice from yet another forum post I added a MIME type for .svc. No change.
6/15/2015 -
- Log file: u_ex150615.log

I got exactly the same issue and finally found a way through it.
The point is that WCF need a integrated pipeline to work properly. In Windows 7's IIS 7.7 I solved the problem by setting the Application Pool to use Integrated Pipeline mode (it was in Classic Mode). But Windows Server 2003's IIS 6 doesn't work with integrated pipeline, so Microsoft .Net uses Web Services Extensions, you could check at IIS 6, right above Web Sites. Ensure that the desired .Net version is allowed in Web Services Extensions. Than you need to register the Service Model extension.
Here´s what I did:
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

Related

HTTP Error 404: Deployment of a Web API (minimal API NET 7) on IIS

I probably have a setup problem on IIS (it's a web server with real URL domain, so accessible from external at any time). I have created a Web API with minimal API NET 7. Before testing out authetification, I tried to reach an endpoint first. I named this endpoint /api/test and defined it as [AllowAnonymous]. On the development server via Swagger everything is already running (also the login or generation of tokens). But in the release web api version I commented out Swagger.
Now when I install the web app on IIS server, then when I call the app via IIS server (but also when I enter the address in browser itself) I get the message: HTTP Error 404.0 - Not Found
Detailed error information is:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error code: 0x80070002
Requested URL: http://api.testapp.com:64591/api/test
Physical path: C:\inetpub\wwroot\Testapp\api\test
Login method: Anonymous
User login: Anonymous
Most likely causes:
The specified directory or file does not exist on this web server.
The URL contains a spelling error.
Access to the file is restricted by a custom filter or module such as URLScan.
But if I run the app in the console via dotnet Testapp.dll, then it is started and if I then enter the URL http://localhost:5000/api/test in the browser, then I get the data.
So it can only be that something has gone wrong with the IIS App setup. By the way I also have ASP.NET Core 7.0 Runtime (v7.0.1) - Windows Hosting Bundle installed. When setting up the app on IIS I used the following guide: http://www.technical-recipes.com/2018/running-asp-net-web-api-services-in-iis/
Can anyone help me with any suggestions?
Thanks
EDIT
Following Lex's suggestion (see his comment below), I installed the Jexus Manager software and ran diagnostics. Here is the report:
IMPORTANT: This report might contain confidential information. Mask such before sharing with others.
System Time: 15.12.2022 10:18:45
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.17763.0
Server Type: IIS
Scan 28 installed module(s).
ASP.NET Core module version 2 is installed for .NET Core 3.1 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (17.0.22323.1).
Scan 44 registered handler(s).
No valid ASP.NET Core handler is registered for this web site.
To run ASP.NET Core on IIS, please refer to https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index for more details.
EDIT 2
I am getting a little closer to the issue. The fundamental error was that I used the app files from the release folder and not from Publish!
I have now copied the app correctly and when I start the app in IIS, browser opens and I can request the data via the Api link!
So locally on the server it works, the problem I have now is that it does not work from external. I get the message:
ERR_CONNECTION_TIMED_OUT
The message also appears in the MAUI application which should use this web api:
A connection attempt failed because the connected party did not respond properly after a period of time, or established connection failed because connected host has failed to respond. (api.website.com:64500)
I started Diagnostic Tool again and I get the following output:
IMPORTANT: This report might contain confidential information. Mask such before sharing with others.
System Time: 15.12.2022 10:33:27
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.17763.0
Server Type: IIS
Scan 28 installed module(s).
ASP.NET Core module version 2 is installed for .NET Core 3.1 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (17.0.22323.1).
Scan 45 registered handler(s).
Found a valid ASP.NET Core handler as { Name: aspNetCore, Path: *, - State: Enabled, Module: AspNetCoreModuleV2, Entry Type: Local }.
Visual C++ runtime is detected (expected: 14.0, detected: 14.24.28127.4 built by: vcwrkspc): C:\Windows\system32\msvcp140.dll.
The application pool 'WebApplication1' is used.
Pool identity is IIS AppPool\WebApplication1
Please ensure pool identity has read access to the content folder C:\inetpub\wwwroot\WebApplication1.
Pool bitness is 64 bit
Scan aspNetCore section.
"processPath": dotnet.
"arguments": .\WebApplication1.dll.
"hostingModel": inprocess.
In-process hosting model is detected. To avoid 500.xx errors, make sure that the bitness of published artifacts matches the application pool bitness
Framework dependent deployment is detected. Skip bitness check.
Found runtime config file C:\inetpub\wwwroot\WebApplication1\WebApplication1.runtimeconfig.json.
Runtime is 7.0.0.
Now it works. If someone else has similar problems (Minimal Api application under NET 7 on IIS), then here are a few tips:
if you release the application, you have to do it via Publish (because e.g. also Web-Config is under Release not generated)
.NET Core Hosting Bundle must be installed on the IIS server.
make sure to open the required ports under Firewall, otherwise external access is not possible
if there should be problems then it makes sense to install the app Jexus Manager and use diagnostic tool in the app.
So, hope I have not missed anything.

How can I deploy an ASP.NET Core Web API project as an IIS sub-application in an existing website using the TFS WinRM - IIS Web App Deployment Task?

I want to deploy an ASP.NET Core Web API project as an IIS sub-application under an existing website using the task WinRM - IIS Web App Deployment with TFS version 15.117.26714.0.
My issue is how to update the path and application name of the project to be deployed so that it can be a sub-application under an existing website. For example, "Default Web Site/sampleapp".
I think I need to update the web.config file that is created after publishing an ASP.NET Core Web API. However, I am not sure how I can do this in an automated fashion using the TFS task WinRM - IIS Web App Deployment task.
Below are my attempts;
Attempt 1
I have attempted to use the Override Parameters section to override the variable "IIS Web Application Name". However, I get an error that says the following;
##[error]Deployment on one or more machines failed. System.Exception: Error: Source does not support parameter called 'IIS Web Application Name'. Must be one of ().Error count: 1.
I believe this is because this task is aiming at ASP.NET projects which include a SetParameters.xml file. However, an ASP.NET Core project does not.
Attempt 2
I have also researched into using the appsettings.json file but this seems to be more for app configuration and not host configuration.
Attempt 3
I've also researched the possibility of a hostconfiguration.json file as suggested by Shaun here; Which values does WebHost read from appsettings.json. However, I don't want to change the source code and I would prefer to use TFS directly.
Attempt 4
Finally, I also don't think I can use publish profiles for this task as that requires the publishing process to be done via Visual Studio or the command line.
So, how do I deploy an ASP.NET Core Web API project as an IIS sub-application under an existing website using the TFS task WinRM - IIS Web App Deployment?
Below are screenshots of the TFS WinRM - IIS Web App Deployment and WinRM - IIS Web App Management tasks for reference.
WinRM - IIS Web App Deployment
WinRM - IIS Web App Management

Run MVC4 webapplication on local IIS webserver

UPDATED - pointed to the wrong directory at first. Thanks for the tip Wiktor. Still not succeeded in running the MVC4 application via
I am trying (for a while now.. :)) to set up a simulated multi tenant webapp on my development PC. I learned that this is not possible with visual studio's internal webserver, so I am trying to set up IIS.
I added the fake tenants in my hosts.
127.0.0.1 localhost
127.0.0.1 tenant1.mydomain.com
127.0.0.1 tenant2.mydomain.com
In IIS I made a new website test(port 8081), and just pointed it to C:\Azure\Websites\. In that directory I added a Hello World html file to see if this bit works.
I navigated to localhost:8081 => Hello world
I navigated to tenant1.mydomain.com:8081 => Hello world.
Cool, first proof of life.
Next step: getting this working with a MVC4 webapp created in VS2012.
I started a new MVC4 webapp and stored it in:
C:\Azure\Websites\MvcApplication1
I just use the default generated website for the test, so I pressed F5 and verified the site is opened in firefox. So the goal is to get this working from IIS.
Created a new website test2 (port 8082)
Set test2 app pool to .net4.0
Point the physical directory to C:\Azure\Websites\MvcApplication1\MvcApplication1\
Navigate to localhost:8082
HTTP Error 500.21 - Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
Uninstalled ASP.NET and reinstalled it again. Same results.
when I change web.config from
preCondition="classicMode,runtimeVersionv4.0,bitness32"
to
preCondition="integratedMode,runtimeVersionv4.0,bitness32"
Then I get this error:
HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
Can I stress the fact that I am a n00b regarding IIS configuration... :)
Any ideas?
ISAPI and CGI Restictions in IIS:
Add isapi dll for .net 4 32bit
Add isapi dll for .net 4 64bit
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
And it works. Finally!
Thanks Wiktor
First configure IIS according this site:
IIS 7.5 handler "extensionlessurlhandler-integrated-4.0" has a bad module "managedpipelinehandler" in its module list
For the above issue, you must go to Control Panel >> Installed Programs and Features >> Repair your .NET Framework by double clicking on it.
first configure IIS as
Manual configuration
Open your Control Panel and click Programs and Features » Turn Windows features on or off.
Turn on Internet Information Services.
Under Internet Information Services, turn on the following features:
Web Management Tools » IIS 6 Management Compatibility » IIS Metabase and IIS 6 configuration compatibility.
Web Management Tools » IIS Management Console, IIS Management Scripts and Tools, and Management Service.
Under World Wide Web Services, turn on the following:
All features under Application Development features, except Server-Side Includes.
Common HTTP Features » Default Document, Directory Browsing, HTTP errors, Http Redirection, Static Content.
Security » Basic Authentication, Request Filtering, Windows Authentication.
Under Microsoft .NET Framework 3.5.1 » Windows Communication Foundation HTTP Activation.
After you have created your website, open the Internet Information Services (IIS) Manger.
Expand your server node.
Expand Sites node and click your website.
In section IIS on the right, double-click Authentication.
Perform one of the following:
If you are using Forms authentication, make sure Anonymous Authentication and Forms Authentication are enabled and all other authentications are disabled.
If you are using Claims-based authentication, make sure only Anonymous Authentication is enabled and all other authentications are disabled.
Click your website again and in IIS section, double-click Handler Mappings.
Make sure you have enabled handler mappings for *.svc and *.xamlx with executable path set to one of the following:
For 64-bit OS: %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
For 32-bit OS: %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Close the Internet Information Services (IIS) Manger.

How to deploy a WCF web service in IIS 8.0 using Visual Studio 2012?

I am stuck and can not figure out how to deploy a wcf web service in iis8.0, can any body please help me out about the detailed process of deploying a wcf web service in iis?
Are there any setting that need to be set?
What have tried is.......
Then i created a new website in iis by giving a site name and physical path (C:\inetpub\wwwroot\NEWFOLDER). Then i opened the VS solution in administrative mode published it. In the dialog box opened, Created a new web application under the IIS Sites and published it.
It was successful and could be seen in output window as well.
when click on the link of the line Connecting to http://localhost:[port#]/WebApplicationName it shows the directory structure.
then clicked on .svc file it gives an error saying
"The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map
WCF Servive handlers are not installed on you server.
In Server Manager
Expand ".Net 3.5" or ".Net 4.5", depending on Os/Framework version.
Under "WCF Services", check the box for "HTTP-Activation" (for http binding) or "Non-http" for others bindings (tcp, named pipes, etc).
Click "Install" Button.
That's all

How to enable Windows Authentication on ASP.NET Development Server?

We are trying to host a WCF service via the web. We set the web.config to have the service require windows authentication. The problem we are having is the following:
When we host our service in a regular IIS, the service runs fine and there is no issues with the "Windows Authentication" mode. However, when we try to run it from our developer boxes we get the following error: "Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service."
Our developers boxes are not hosting the service through the regular IIS but rather through Visual Studio's ASP.NET Development Server. We tried going into the web project properties and said to enable NTLM authentication but that still did not fix it. Does anyone know how to fix it? Does VS ASP.NET Development Server even support Windows Authentication? Is the only option for hosting the service with Windows Authentication is to use IIS and forget about ASP.NET Development Server?
In order to configure IIS Express security settings:
look for the IIS express symbol in the taskbar (system tray).
Right click and select "All Applications".
Click on the name of the site you want to change (although I believe the change is site wide)
Click on the path in the config section below (it will open the applicationhost.config file)
Search for the authentication section and make your changes
Example changes can be found here:
http://toadcode.blogspot.ca/2011/08/security-config-in-iis-express.html
ASP.Net Development Server is very limited. It only serves requests originating from the same machine that it is running on, and it will not serve files that are outside of its application scope. It is based on the Cassini server. Cassini does not support WCF web services. Documentation for ASP.Net Development Server says that it does support NTLM. If you are just browsing to a page from the local machine it should work fine unless the page is referencing an unavailable resource.
check out http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx for more info.
I would install and configure IIS on your local dev machine and use that in preference to using the inbuilt webserver. To use local IIS to debug select "User Local IIS web server" on the web tab of the project properties. Using IIS rather than the inbuilt webserver also means that you can configure your app in exactly the same way as it will be configured on the production server and this will reduce the no of potential surprises when you move to the production environment.
The solution to my authorization issue was to go into the F4 project properties and set the following:
Anonymous Authentication: Disabled
Windows Authentication: Enabled
Apparently these properties update the IIS applicationHost.config directly.
http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/

Categories

Resources