I realize posts like this exist, I've read/re-read and am still having issues. Most are old or not directly related and so I thought I'd re-post w/a current example.
Trying to get a basic site running in IIS 8.5+ on win server 2012 R2. At this point I'm stuck at "502.3 - Bad Gateway" (error code 80070002, module httpPlatformHandler, notification executeRequestHandler, handler httpplatformhandler)
Relevant info:
dnx 1.0.0-rc1-final clr (x64)
IIS - installed/verified HttpPlatformHandler 1.2 is installed (v1.2.1959)
IIS - setup a "No Managed Code" pool/site
On the server itself I can get the site to show up if i run the "kestrel.cmd" (generated via dnu publish) directly, from the command line and navigate to the site.
Project.json:
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
},
"commands": {
"kestrel": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {}
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"www",
"node_modules",
"bower_components"
],
"scripts": {
"prepublish": [
"npm install",
"bower install"
]
}
}
Web.config generated after dnu publish:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="approot\kestrel.cmd" arguments="" stdoutLogEnabled="true" stdoutLogFile="logs\stdout.log" forwardWindowsAuthToken="false" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
Your help is much appreciated.
I was getting the same issue - iis 8 - bad gateway 502.3.
I went to Turn Windows Features On or Off and enabled IIS.
I cleaned and rebuild the solution and it ran like a charm.
I hope it helps you too.
Related
I am trying to get the .Net and VSCode working on Ubuntu 20.04. "dotnet run" command does run the program ok, but running it in VSCode is giving me the following errors:
Starting OmniSharp server at 7/7/2020, 6:28:24 PM
Target: /home/ivlatin2012/Projects/HelloDotnetCore
OmniSharp server started with Mono 6.8.0.
Path: /home/ivlatin2012/.vscode/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/omnisharp/OmniSharp.exe
PID: 14939
System.TypeLoadException: Could not load type of field 'McMaster.Extensions.CommandLineUtils.CommandLineApplication:_validationErrorHandler' (36) due to: Could not load file or assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
at OmniSharp.Stdio.StdioCommandLineApplication..ctor () [0x00000] in <11f4106bfdfd41759d0a0dc35f30dcd7>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00006] in <be19315b4efc4538b70abd1dc15c63a1>:0
at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <a3beccf5923c417282767eebc9bf25e1>:0
There's really not much to the Program.cs file I am running
using System;
namespace HelloDotnetCore
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
The launch.json file looks like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
}
],
]
}
The .csproj file looks like this
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
</Project>
Any help would be really appreciated. I'd been away from anything .Net for the last several years, and am completely new to .Net Core. This is a part of a Pluralsight class I'm trying to follow, but have gotten stuck with VSCode & Omnisharp.
The only thing I could find is this
Github issue with Mono
You could try to add the setting: "omnisharp.useGlobalMono": never and see if that works for you.
For me, following steps worked:
Go to C# Extension settings
Set the Omnisharp: Use Global Mono to "Never"
picture example
I have the following issue while trying to start IIS Express using Visual Studio Professional 2015 to run an ASP.NET 5 MVC 6 web application - DNX RC1 (Update 2) on Windows 10:
Error Returned:
HTTP Error 502.3 - Bad Gateway
The specified CGI application encountered an error and the server terminated the process.
Most likely causes:
- The CGI application did not return a valid set of HTTP errors.
- A server acting as a proxy or gateway was unable to process the request due to an error in a parent gateway.
Detailed Error Information:
- Module: httpPlatformHandler
- Notification: ExecuteRequestHandler
- Handler: httpPlatformHandler
- Error Code: 0x80072ee2
The curious thing is that I started the same web application in a different operating system (Windows 7) and IDE (Visual Studio Community 2015). For this case I have no issues and web application runs properly. And I make sure to configure the same DNX as active on both operating systems (6.0.0-rc1-final). The only thing that vary is the framework architecture (Windows 7 =[x64] / Windows 10 =[x86]).
Down below I am also providing relevant configuration files to complement findings:
1. project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"AutoMapper": "4.2.1"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"dependencies": {
"AutoMapper": "4.2.1",
"System.Net.Http": "4.0.1-rc2-24027"
},
"frameworkAssemblies": {
"System.Data.Entity": "4.0.0.0"
}
},
"dnxcore50": {
"dependencies": {
"System.Net.Http": "4.0.1-beta-23516"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
2. web.config (wwwroot)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>
3. global.json
{
"sdk": {
"version": "1.0.0-rc1-update2"
}
}
Finally, last topics that may help to find the error:
- I am not pretty sure if httpPlatformHandler was installed correctly. Where can I find it or make sure it is?
- I have other web projects hosted on IIS Local, with virtual directories and assigned pools. How might this affect port's availability, considering that IIS Express is targeting into port 8000? (App URL: http://localhost:8000/)
If you require additional information for this issue, please let me know.
Thanks in advance!
Karen G.
I'm writing an intranet site using ASP.Net Core. I've created the site in VS2015 and selected to use windows authentication. I now need access to the current user account name in my server code. I'm fairly new to this, so I could be wrong, but I believe I should be using User.Identity.Name? When I look at this though, it's null. I'd previously been running the site using self-hosting and had read somewhere that this was to be expected if you were hosting use the generated web.cmd entry point, but would work okay under IIS. I'm now running it under IIS though, but I'm seeing the same behaviour. Can anyone point me at what I'm missing?
This is my web.config file:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="--server.urls http://address:5001" stdoutLogEnabled="true" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600" forwardWindowsAuthToken="true"></httpPlatform>
</system.webServer>
</configuration>
The site is running okay under IIS using this config, apart from the Identity problem. Within ISS I have disabled everything but Windows Authentication for the site using the Authentication settings accessed from the site Features view
In case it's needed, here is a section of my project.json file with dependencies, commands and frameworks:
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",
"System.DirectoryServices.Linq": "1.2.2.1",
"AutoMapper": "4.2.1"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef" : "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Services": "1.0.0-*"
}
}
},
There's a bug in the IISPlatformHandler module that requires your to map your app's base URL to a virtual directory (as I understand the solution, anyway!!). Rather annoyingly I'd come across this before posting the question, but it didn't seem to work. I can only assume I'd been trying so many things that I'd mucked up my test the first time round. The site now works perfectly under IIS
Here's the code change to make in your startup class:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
app.Map("/SomeBasePath", (app1) => this.ConfigureInternal(app1, env, loggerFactory));
}
public void ConfigureInternal(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
// your original call to Configure here
}
So you're basically renaming your original Configure method, and calling it from a new Configure method that does the mapping.
Let's say your site was running as http://webserver:1234/Home previously. After this change you would need to access it as http://webserver:1234/SomeBasePath/Home. This was fine for our site, so I'm not sure how you'd do it without the extra node in the URL, if you needed to.
[SOLVED]
I logged a bug against TypeScript and the fix should be rolled up into the next VS plugin release. Essentially you can get intellisense to work if you specify your module resolution to be "NodeJs". However the compiler doesn't like this because it expects it to be "node". It looks like the fix they're making is to make everything work by specifying "Node".
I'm trying to build an Angular2 project with msbuild because I want to use ASP.Net Web API as my back-end. The code compiles and runs fine, but my editor (SublimeText 3 or Visual Studio 2015) doesn't like the way I import the Angular2 libraries:
boot.ts:
import {bootstrap} from 'angular2/platform/browser'; // error: cannot find module
import {AppComponent} from './app.component';
bootstrap(AppComponent, []);
If I run the same example (Angular2 Hero Tutorial) using the TypeScript compiler directly with a tsconfig.json and node lite-server as documented, then SublimeText3 works and can recognize this syntax just fine. However once I switch to msbuild, I get this intellisense error for some reason. Here's other pieces of my project which I think are relevant:
Folder structure:
\
- index.html
- package.json
\app
- boot.ts
- app.component.ts
\node_modules
\angular2
\platform
- browser.js
- browser.d.ts
package.json:
{
"name": "angular2-webapi",
"version": "1.0.0",
"scripts": {
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"typescript": "^1.7.3"
}
}
TypeScript compiler section from csproj file (most of this was copied from the Angular2 Hero tutorial tsconfig file, but some of these were set by VS automatically):
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptJSXEmit>None</TypeScriptJSXEmit>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>System</TypeScriptModuleKind>
<TypeScriptRemoveComments>False</TypeScriptRemoveComments>
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>
<TypeScriptModuleResolution>node</TypeScriptModuleResolution>
<TypeScriptEmitDecoratorMetadata>true</TypeScriptEmitDecoratorMetadata>
</PropertyGroup>
I've also tried changing the way I reference the Angular2 libraries like below since it matches the actual physical path of the browser script, but unfortunately the generated file doesn't add the ".js" extension to the generated dependency list for some reason. This means that the browser will request the file "browser" instead of "browser.js".
This breaks the runtime:
import {bootstrap} from '../node_modules/angular2/platform/browser';
I'm actually not sure how the system is supposed to know how to resolve the 'angular2/platform/browser' syntax, but it seems to work if I don't use msbuild. And given the fact that this code compiles and runs properly, it seems like it should work in my editor as well. Anyone have any ideas?
As far as project property group is set to
<TypeScriptModuleResolution>NodeJs</TypeScriptModuleResolution>
there is a workaround is to modify Microsoft.Typescript.targets.
It makes compiler to work:
<TypeScriptBuildConfigurations Condition="'$(TypeScriptModuleResolution)' != ''">$(TypeScriptBuildConfigurations) --moduleResolution $(TypeScriptModuleResolution)</TypeScriptBuildConfigurations>
hardcoded as
<TypeScriptBuildConfigurations Condition="'$(TypeScriptModuleResolution)' != '' and '$(TypeScriptModuleResolution)' != 'NodeJs'">$(TypeScriptBuildConfigurations) --moduleResolution $(TypeScriptModuleResolution)</TypeScriptBuildConfigurations>
<TypeScriptBuildConfigurations Condition="'$(TypeScriptModuleResolution)' == 'NodeJs'">$(TypeScriptBuildConfigurations) --moduleResolution node</TypeScriptBuildConfigurations>
PS make sure to take a backup of Microsoft.Typescript.targets
This does appear to be a bug in typescript tooling as #AndrewSorokin describes, but instead of editing Microsoft.Typescript.targets, you can override the incorrect code in your project file. Add the following lines to the end of your project file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ... -->
<!-- Set the Module Resolution mode to be NodeJs as required by intellisense -->
<!-- See http://stackoverflow.com/questions/34939261/how-can-i-get-visual-studio-typescript-1-7-intellisense-to-work-with-nodejs-libr -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<TypeScriptModuleResolution>NodeJs</TypeScriptModuleResolution>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<TypeScriptModuleResolution>NodeJs</TypeScriptModuleResolution>
</PropertyGroup>
<!-- ... -->
<!-- Override the moduleResolution parameter to tsc to overcome a bug in intellisense -->
<!-- See http://stackoverflow.com/questions/34939261/how-can-i-get-visual-studio-typescript-1-7-intellisense-to-work-with-nodejs-libr -->
<PropertyGroup>
<CompileTypeScriptDependsOn>
SpoofTypeScriptModuleResolution;
$(CompileTypeScriptDependsOn)
</CompileTypeScriptDependsOn>
</PropertyGroup>
<Target Name="SpoofTypeScriptModuleResolution">
<PropertyGroup>
<TypeScriptBuildConfigurations>$(TypeScriptBuildConfigurations.Replace('--moduleResolution NodeJs', '--moduleResolution node'))</TypeScriptBuildConfigurations>
</PropertyGroup>
<Message Text="Options: $(TypeScriptBuildConfigurations)" />
</Target>
</Project>
I'm trying to deploy an ASP NET 5 Web App on IIS but there´s no way to make it works, it gives me the following error:
Failed to resolve the following dependencies for target framework
'DNX,Version=v4.5.1': ....(a list with all the dependencies of my
project)
It seems thats is unable to resolve the path to the dependencies, but if I check on 'approot' folder they are all there.
My 'project.json' is this:
"dependencies": {
"EntityFramework": "7.0.0-beta4",
"EntityFramework.Commands": "7.0.0-beta4",
"EntityFramework.Core": "7.0.0-beta4",
"EntityFramework.SqlServer": "7.0.0-beta4",
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"Newtonsoft.Json": "7.0.1",
"System.Xml.XmlDocument": "4.0.0-beta-22816"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { }
}
Also the paths from web.config in 'wwwroot' folder seems to be ok:
<appSettings>
<add key="bootstrapper-version" value="1.0.0-beta4" />
<add key="runtime-path" value="..\approot\packages" />
<add key="dnx-version" value="1.0.0-beta4" />
<add key="dnx-clr" value="clr" />
<add key="dnx-app-base" value="..\approot\src\Astarte" />
</appSettings>
I'm really stucked, ¿any idea of what could be the problem?
You may need to specify the version of the sdk you require (in your case 1.0.0-beta4). Try adding a global.json file in your appication root with the following:
{
"sdk": { "version": "1.0.0-beta4" }
}
*On a side note, as #Henk Mollema has said you should probably upgrade at some point to a more recent beta, as beta4 is now quite old. Please beware however that this will cause breaking changes so you may want to tackle this separately!