Forbidden to browse WCF svc file? - c#

I am using VS2010 + C# + .Net 4.0 + IIS 7.5 + Windows 7. When I open an svc file (in IIS manager, right click the svc file and select browse) for a WCF project in IIS, there is an error like this, any ideas what is wrong?
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.svc' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Here is the content of the web.config file I am using, is it correct?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svc" />
</staticContent>
<handlers>
<remove name="svc-ISAPI-2.0" />
<remove name="svc-Integrated" />
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
</system.webServer>
</configuration>

You may have to launch the command servicemodelreg –ia in Visual Studio command prompt.
If it's not working, check if you have "WCF http activation" feature installed (Add/Remove Programs - Turn Windows Features On or Off - Microsoft .Net 3.5.1).
UPDATE 1: Probably your application is hosted under .NET 2.0 App Pool. Go to IIS Manager and check for Basic Settings… link. Click Select button and you will see which option are you using. Change it to use .NET 4.0
UPDATE 2: Your web.config file seems incomplete. I suggest you to configure your service using WCF Configuration Editor tool. Launch it (make sure you are using .NET 4 version of the tool) and open your web.config file. Create service configuration and service endpoint configuration, then save it.

Its likely the mime types not setup correctly on IIS, try using the aspnet_regiis tool. Failing that, I'd recommend adding a mimetype to your virtual directory in iis for .svc files to be handled by the .NET runtime.

Related

web_Config file configuration under IIS 10

I have a site on IIS server which hosts ASP.NET REST APIs. They work on separate application pools which all have Unmanaged Code as their .NET CLR version. All .NET Core APIs .NET Core 3.1 written.
I have also installed hosting bundle, SDK, ASp.NET And Desktop SDKs as shown below.
Unfortunately the app does not work. When I investigate it seems the error is IIS/configuration related. The application I have deployed is published as follows :
And the web.config is as follows :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<!-- The line below -->
<aspNetCore processPath=".\Unity.REST.API.WM.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
With this configuration, when I try to open Configuration Manager of the site under Management tab I get the following error.
However if I remove the line under the "The line below" comment, I can view configuration, but I certainly need to keep that line to make my .NET Core REST API working.
I have copied all the files and config from another server and it works OK there. Is there any possible solution you can suggest?
In applicationhost.config, check if you have such an entry:
<section name="aspNetCore" overrideModeDefault="Allow" />
Believe it should be under <configuration> -> <configSections> -> <sectionGroup name="system.webServer">
If you don't have it, try adding it and restart IIS.
This problem occurs because the ApplicationHost.config or Web.config file contains a malformed or unidentified XML element. IIS can't identify the XML elements of the modules that are not installed. You can find probloem element by commenting some blocks and looking for type of error.
And you can also try to check whether URL rewrite is installed.
https://www.iis.net/downloads/microsoft/url-rewrite.

Error trying to host an ASP.NET 2.2 Website on Plesk Onyx 17.8.11 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

I'm attempting to host a ASP.NET 2.2 Website on a interserver.com shared hosting platform. They are using Plesk Onyx version 17.8.11 as their hosting platform control panel.
I've verified the hosting is routed and setup correctly but still get the runtime error:
HTTP Error 500.0 - ANCM In-Process Handler Load Failure
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found
The in process request handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the application
ANCM could not find dotnet.
I reported the issue to customer service and they have sent me a few articles of things to try but no solution has been found. Since the error says that the key aspnet core library could not be found, they said they have "installed .NET core 2.1.10 and 2.2.2 hosting bundle" but I'm still getting the same error.
The web.config on the host (auto-generated) is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\BridgeSite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 7bcb9c33-cd6b-4078-9742-869d5dd7bxxx -->
Any suggestions stackoverflow family?
Since this is a shared hosting platform I do not have access to fiddle around with server configurations. From what I can tell, something went wrong with the ASP.NET Core 2.2.4 runtime installation and AspNetCoreModuleV2.dll is missing/corrupt/misplaced?
After spending far to much time on this I found a couple workarounds:
Every time you publish, go to the folder on the host where the code was published, open the auto-generated web.config, under the handlers node replace "AspNetCoreModuleV2" with "AspNetCoreModule". This works, by defaulting it back to the previous package, but is crappy because it has to be done manually every time the code is published.
OR,
in the Visual Studio solution, open (or create new) publish profile under Properties > PublishProfiles. In the PropertyGroup add: <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>. This works but is a big hack and the application will not have all the performance gains of being InProcess (Default)
After testing, I found you can use one or the other, you don't have to use both.
I'm hoping this issue will resolve itself over time as the hosting service continues to update their runtimes, but for now hopefully those workarounds will help you too.
This error is documented, along with the solution:
500.0 In-Process Handler Load Failure
The worker process fails. The app doesn't start.
The ASP.NET Core Module fails to find the .NET Core CLR and find the in-process request handler (aspnetcorev2_inprocess.dll). Check that:
The app targets either the Microsoft.AspNetCore.Server.IIS NuGet package or the Microsoft.AspNetCore.App metapackage.
The version of the ASP.NET Core shared framework that the app targets is installed on the target machine.
The most likely scenario is that you've failed to installed the .NET Core runtime at all or at least failed to install the correct version thereof to match what your project is targeting.
For Asp.Net Core 2.2 MVC.
1. Create web.config at the root on the Project.
2. Past this configuration:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
I was having the same issue with Interserver.com.
Support was able to solve the problem by switching my application pool to 64 bit. From what I have read in regards to other Plesk hosting providers is that by default the scripts that create your virtual machine by default create the application pool in 32 bit. I'm guessing that AspNetCoreModuleV2 requires 64 bit, but that is just a guess. Happy that my site is running in process now.

Why does Asp.Net Core 2.1 WebApi return a 500.19 error?

I have a small webapi service, which works under Visual Studio but doesn't work under IIS.
I did the next:
New application was added to the default web-site in IIS console.
Application was published into app folder from VS via File System
(Framework-dependent and Portable options were selected).
When I try access folder with my app (like http://localhost/example/) I receive 500.19 error with code 0x8007000d. I read this error can happen if ApplicationHost.config or Web.config has wrong XML options. I use default Web.config file (ApplicationHost.config is not used by me) which VS generate, and I don't understand what can be bad in it. Here's my Web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Service.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
Lex Li wrote an excellent article: https://blog.lextudio.com/the-horrible-story-of-publishing-net-core-web-apps-for-beginners-6121662dd8c4, which described issues with publishing .NET Core Web Apps.
In my case, I hadn't installed the ASP.NET Core Hosting Bundle. A simple solution which is hard to be found because it is difficult to understand what should be searched for.
I ran into the exact same issue and in addition to the marked correct answer, this is what worked for me:
I installed the ASP.NET Core Hosting Bundle and was still receiving the same error.
Repairing the installation resolved my issue.
Programs and Features -> Repair "Windows Server Hosting"
"If the Hosting Bundle is installed before IIS, the bundle installation must be repaired. Run the Hosting Bundle installer again after installing IIS.
If the Hosting Bundle is installed after installing the 64-bit (x64) version of .NET Core, SDKs might appear to be missing (No .NET Core SDKs were detected). To resolve the problem, see Troubleshoot ASP.NET Core projects." - Install the .NET Core Hosting Bundle

.net core application error 502.5 if run as virtual directory in IIS

I am having problem configuring .net core application to work as virtual directory in iis.
If i start .net core application directly with its port it works fine.
I am getting 502.5 response and in event viewer there is this message
Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE' with physical root 'C:\inetpub\wwwroot\' failed to start process with commandline ' ', ErrorCode = '0x80070057 : 0.
I have removed parent handlers in .net web.config like this
<handlers>
<remove name="httpPlatformHandler"/>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
</handlers>
In order to run an ASP.NET Core application make sure you:
Have the ASP.NET Core Web Hosting Bundle (required for a server!)
Publish your application - should include a web.config
Deploy the Publish output to your server
Set up an Application Pool
Set .NET Framework to none (optional but usually a good idea)
Use an account that has read permissions in the virtual folder
The hosting bundle includes the ASP.NET Core Module for IIS which allows IIS to launch. Without ASP.NET Core apps will not run on IIS.
You also need to publish your application, which produces a final output folder that contains your binaries and config files including a web.config in the root and a wwwroot root folder with your content. To test you should make sure you can run your app from the command line with:
dotnet yourMainAssembly.dll -c Release
If this doesn't work fix this first as this is essentially what IIS fires. once the standalone works you can try using IIS.
ASP.NET Core projects created in Visual Studio automatically include a web.config and that should have everything you need to run under IIS. For a basic setup that should be all you need. The generated web.config should take care of getting your app running.
If you're using a virtual you might have an issue with the parent side configuration bleeding into your virtual because virtuals inherit settings from the parent. If that's the case either choose the same version of .NET Framework for your application pool, or share the application pool with the parent. Alternately you can use <clear /> in the <handlers> section to clear out any handlers from up the hierarchy.
<configuration>
<system.webServer>
<handlers>
<clear>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
<environmentVariables />
</aspNetCore>
</system.webServer>
</configuration>
I have a blog post with a lot more details on hosting on IIS along with some additional configuration for static files here:
Publishing and Running ASP.NET Core Apps under IIS
IIS Rewrite Rules and Static File Configuration for ASP.NET Core

Getting "The WebResource.axd handler must be registered in the configuration to process this request." error

I'm getting this error while running my ASP.NET app on IIS7. I've tried doing what it says to do but it doesn't help.
The WebResource.axd handler must be
registered in the configuration to
process this request.
> <!-- Web.Config Configuration File -->
>
> <configuration>
> <system.web>
> <httpHandlers>
> <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
> </httpHandlers>
> </system.web>
> </configuration>
I'm using a little bit of AJAX which is what I think is causing the issue. Has anyone encountered this before?
I figured it out so I'm posting it here for search reasons. It is a bug in ASP.NET and it has to do with having ColdFusion installed. Microsoft hasn't yet released a fix.
There are two ways to fix this.
Change the AppPool in IIS7 to "Classic .NET AppPool". I'm not sure of any implications with this setting.
Remove all the references to ColdFusion from your applicationHost.config file in system32\inetsrv\config.
ColdFusion installs a global wildcard handler mapping which apparently overrides many of the standard .NET handlers. The solutions mentioned work just fine, but if you can't switch to Classic Mode and don't want to screw with your ColdFusion installation, you can remove the inherited handler mapping at the individual site level.
To do this, go to the site in question in IIS, double-click on "Handler Mappings" under the "IIS" section, and find the handler named something like "AboMapperCustom-XXXXXX" with "*" for the Path. Select the entry and click "Remove" in the sidebar. This will only remove the mapping for your application, so it won't break any existing CF sites on the server.
In IIS7 you need to add the <httpHandler> section to <system.webServer> instead of <system.web>. Here is an example.
I got this error after carelessly copying my app's web.config between a pair of clustered servers, which overwrote the tag:
<system.webServer>
<handlers>
<remove name="AboMapperCustom-XXXXXXXX" />
</handlers>
</system.webServer>
with
<system.webServer>
<handlers>
<remove name="AboMapperCustom-YYYYYYYY" />
</handlers>
</system.webServer>
Locating the proper ID as per Josh's response and correcting the tag fixed it, but more importantly, will presumably keep that handler mapping from sneaking back in.
The issue happened to me on new Windows 2016 server where ASP.NET 4.6 was not installed. After installation everything got fixed.
Steps
- Run Server Manager
- Manage > Add Roles and Features
- Server Roles
- Web Server (IIS) > Web Server > Application Development > ASP.NET 4.6
I had this problem and that reason was incompatibility between Coldfusion and some configurations of ASP.NET applications when IIS App pool is in integrated mode. Coldfusion must be disable .

Categories