问题
Why won't the "out of the box" aspnet5 web application project run with the frameworks section set to the TFM "net46" or "net451". I can only get it to run set to "dnx451 or dnx46". If I run it under any of the "netxx" monikers I get a connection refused in the browser instead of the aspnet splash page.
UPDATE 1 I get the following when I switch the TFM to "net46" in the project.json file so why is it still targeting the dnx 4.5.1 runtime? Current dnvm shows as above and on another note you can switch from IISExpress to web in the droplist under the debug button right in VS2015 as well.
C:\Users\Doug\Documents\Visual Studio 14\Projects\WebApplication2\src\WebApplication2>dnx web
System.InvalidOperationException: The current runtime target framework is not compatible with 'WebApplication2'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
Version: 1.0.0-rc1-16231
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86
Please make sure the runtime matches a framework specified in project.json
at Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicationName)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)
C:\Users\Doug\Documents\Visual Studio 14\Projects\WebApplication2\src\WebApplication2>dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 clr x64 win
* 1.0.0-rc1-update1 clr x86 win default
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
FYI again this is the out of the box WebApplication project for aspnet5 and here is my project.json
{
"userSecretsId": "aspnet5-WebApplication2-59e2cf64-0111-49ef-89d6-ab19ba2a9788",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.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.Configuration.UserSecrets": "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",
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"net46": { } <--- THIS HAS TO BE DNX45,DNX451, or DNX46 for it to run
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
来源:https://stackoverflow.com/questions/34977129/aspnet5-default-web-application-project-wont-run