I am trying to deploy a website to an IIS webserver but I keep getting a 403 forbidden error. I have tried all the solutions on this question but to no avail so I was wondering what else could be causing the 403
When I publish a different site to the same folder with the same app pool it will run and the only difference between the 2 sites is the one that isn't working is .net 4.5 and the one that is is .net 4
Has anyone got any ideas what may be causing the site to throw a 403 - I have checked the event viewer and nothing seems to be showing up
After trying and failing with a lot of things, I have found that it was due to the routing with MVC and adding the following line into my web config seems to have fixed it:
<modules runAllManagedModulesForAllRequests="true"></modules>
Put this in your web.config file:
<system.webServer>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
Also copy to the bin folder on IIS any missing DLLs it complains about (like. System.Web.Http). Set them to copylocal=true in VS to prevent this error in future.
The other anwswer to this question (
<modules runAllManagedModulesForAllRequests="true"></modules>
) runs all modules all the time. According to this blog it's too drastic and will lead to errors and slow speeds: http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html
Related
I've inherited a class library that is using .NET Framework 4.7.2. In the library there are a bunch of ApiControllers with a number of HttpPost and HttpGet Methods on them. Errors have started occurring on some of the methods and these methods are typically called from a wordpress site.
To try and make things a bit easier for me to debug, I'm trying to install swagger into the solution. I've installed Swashbuckle.core with a runtimne version of 4.0.30319 and this has created a basic SwaggerConfig.cs file in my App_Start folder.
In the properties for the solution the project url is http://localhost/WordpressService and it's running under local IIS.
I have a local version of wordpress running in Microsoft Edge, and in IIS I can see that the WordpressService is running on port 80.
So now in the WordpressService solution I try to attach the debugger to the browser, then in the browser I try to enter http://localhost/WordpressService/swagger and other variations of the address, but all the time I receive the following error:
HTTP Error 500.21 - Internal Server Error Handler
"ExtensionlessUrlHandler-Integrated-4.0" has a bad module
"ManagedPipelineHandler" in its module list
I have this section in my web.config file:
<system.webServer>
<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" />
</handlers>
</system.webServer> >
within IIS in the Handler Mappings section I can see ExtensionlessUrlHandler-Integrated-4.0 and it is enabled.
it also suggests that asp.net may not be installed correctly but it must be as I'm using VS 2017 and would need to be there for that. Looking around the net, the default SwaggerConfig.cs should be enough to get me going.
The only thing I can think of is that I may have installed the wrong version of swagger, but I'm not sure in that case which version I should be installing for this .NET Framework.
Ok, I figured the issue out and thought I'd post my answer for anyone else that may come across this issue. From IIS installation, it appears that only Framework 3.5 had been installed and not Framework 4.8. Installing 4.8 in the IIS section seems to have resolved this and I can now see my end points via swagger.
Ok - this is my first deployment of an ASP.NET Core app. One wrinkle to keep in mind is that I am using ASP.NET Core 2.2 and targeting Framework version 4.6.2 (not .Net Core). It all runs fine on my local machine with VS2017 and IISExpress.
I went through the procedure outlined by MS here: Host ASP.NET Core on Windows with IIS The documentation is long and complicated, but I think I covered everything. It makes one thing clear: The in-process hosting model isn't supported for ASP.NET Core apps that target the .NET Framework. So, I know I need to use Out-of-Proc.
Some other points:
I published the app to a local folder and copied it to the server without any changes.
I created the new app in the Default Web Site and gave it its own app pool - set as "No Managed Code"
Out-of-proc is the default, so I have not done any special config for this.
I have confirmed that AspNetCoreModuleV2 appears in the list of Modules.
The Result
Every page I hit I get HTTP404. I am running IE locally on the server and using a URL like: http://localhost/MyApp/Home/MyView
The application pool shows having 1 application running.
The App Event Log shows a message like: Application '/LM/W3SVC/2/ROOT/MyApp' started process '8864' successfully and process '8864' is listening on port '37706'. It shows no errors.
I have tried adding a default.htm file to the root of the app and loading the static page directly (using http://localhost/MyApp/default.htm). This gives 404. If I remove the web.config, this page will load.
I really didn't expect deploying the app to be this complicated.
Can anyone provide any guidance on how to troubleshoot or fix this problem?
Update 1: Web.config is below. I have tried with and without hostModel=... aspNetCore logs show successful startup. Nothing is added to the log with each page access attempt (seems weird)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
<remove name="BlockViewHandler" />
<add name="JavaScript" path="*.js" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="CSS" path="*.css" verb="GET,HEAD" type="System.Web.StaticFileHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
<aspNetCore processPath=".\My.App.Name.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess">
<environmentVariables />
<handlerSettings>
<handlerSetting name="debugLevel" value="file" />
<handlerSetting name="debugFile" value="d:\Log\MyApp.log" />
</handlerSettings>
</aspNetCore>
</system.webServer>
</configuration>
<!--ProjectGuid: ee76911e-decb-48b7-bd74-36ebfbdb22b6-->
Solved! I was making use of the ASPNETCORE_ENVIRONMENT environment variable, but was unaware that the publish process does not put this in web.config. I added this to Web.config:
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
and the pages now load.
The most useful diagnostics I found were at this link Troubleshoot ASP.NET Core on IIS There they recommended that I run My.App.Name.exe from the command prompt. This creates a web process and assigns it to a port and gives you all the console output. This allowed me to figure out it was actually half working and that led me to the fact that I was missing the Env Variable.
Thanks again for the suggestions...
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.
I've created an OData service (WCF Data Service), and a consumer to test it.
Previously, when I attempted to delete, I got the WebDAV 405 error message, "Method Not Allowed".
So I googled and found:
http://nikhilthaker86.wordpress.com/2010/03/27/issue-hosting-restful-services-on-iis-7/
I followed the instructions and removed the WebDav module from my website (service) in IIS 7.
Now I get this error message instead:
"HTTP Error 500.21 - Internal Server Error
Handler "WebDAV" has a bad module "WebDAVModule" in its module list
Module: IIS Web Core
Notification: ExecuteRequestHandler"
If you have a solution that will make this problem go away, I would really appreciate it... otherwise, if you're an IIS guru, and you're thinking "This guy has no idea what he's doing", please point me in the direction of some useful online reading material.
Thanks in advance.
The WebDAV module will block both the DELETE and PUT (update) verbs for IIS. You can either uninstall WebDAV (recommended) or simply remove it from the Handlers of the site. More details can be found here: http://forums.iis.net/t/1166025.aspx
One way to do this is to add the following remove lines to your site's web.config:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
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 .