UPDATED
I have published my solution to an azure web app. No errors arose, but when I browse to the page it doesn't display at all (a GET request is issued but the server does not respond for a long time and eventually returns a 500 error).
I think the problem might be that dnx is listening on http://localhost:5000, which is obviously not the Azure app site.
I deduced this by opening a Kudu debug console, and then running site\approot\web.cmd, which generates the following output:
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
Azure Web Sites environment detected. Using 'D:\home\ASP.NET\DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
But I can't work out how to change this. I have searched my entire source code and the environment variables, and the only reference to localhost is in Properties/launchSettings.json:
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55071/",
"sslPort": 44391
Here are what appear to be the relevant files:
global.json:
{
"projects": [
"src"
],
"sdk": {
"version": "1.0.0-rc1-update1"
},
"packages": "packages"
}
Project.json:
{
"userSecretsId": "aspnet5-Kado-#######",
"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.CodeGenerators.Mvc": "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",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc1-final",
"Microsoft.jQuery.Unobtrusive.Ajax": "3.2.3",
"System.Runtime": "4.0.21-beta-23516",
"Bootstrap.Datepicker": "1.6.0",
"bootstrap-select": "1.10.0",
"Newtonsoft.Json": "8.0.2",
"Stripe.net": "6.0.1",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnxcore50": {
"dependencies": {
"System.ComponentModel.Annotations": "4.0.11-beta-23516"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
Startup.cs includes the following code:
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
web.config:
<?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%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
</system.webServer>
</configuration>
Related
I am getting following error while running the publish asp.net core RC1 website on the Windows Server using web.cmd,
Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'
The publish website has runtime included.
Here is my project.json file,
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"DocX": "1.0.0.19",
"EntityFramework": "6.1.3",
"EntityFramework.Core": "7.0.0-rc1-final",
"iTextSharp": "5.5.9",
"itextsharp.pdfa": "5.5.9",
"itextsharp.xtra": "5.5.8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "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.Net.Http": "2.2.22",
"Newtonsoft.Json": "8.0.3"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"WebApi.Core": "1.0.0-*"
},
"frameworkAssemblies": {
"System.Data": "4.0.0.0",
"System.Drawing": "4.0.0.0",
"System.Messaging": "4.0.0.0",
"System.Transactions": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
The publish content has a dependency 'WebApi.Core' which is added as a nuget package. Actually its a another class library project in my solution.
I have tried dnu restore but it is giving problem for the WebApi.Core dependency.
Same publish content is running fine on my Windows 10 local machine.
Please let me know if you guys have any solution to resolve this problem.
Try deleting the global.json file from the hosted folder. It would be at approot or at approot\src[projectName].
If that doesn't work, try running the commands dnu list, dnu restore, dnu build
as per this:
https://stackoverflow.com/a/34212116/2168359
We try to host an ASP.Net core MVC RC1 DNX project on Service Fabric. The deployment works but the project is not starting. According to our log it seems service fabric cannot find the startup class and create an instance. We downloaded a demo project that works fine, but we cannot bring our project up and running. We cannot see any peace of helpful log information. Not in event log, service fabric log stream or with visual studio debug prompt. Is there anything we can do to enable more debug information. What could be wrong on our configuration, or project setup? This are the Key parts of our project:
ServiceManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WebPkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<StatelessServiceType ServiceTypeName="WebType" >
<Extensions>
<Extension Name="__GeneratedServiceType__">
<GeneratedNames xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
<DefaultService Name="WebTypeService" />
<ServiceEndpoint Name="WebTypeEndpoint" />
</GeneratedNames>
</Extension>
</Extensions>
</StatelessServiceType>
</ServiceTypes>
<CodePackage Name="C" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>approot\runtimes\dnx-clr-win-x64.1.0.0-rc1-update2\bin\dnx.exe</Program>
<Arguments>--appbase approot\src\Sportflash.Web Microsoft.Dnx.ApplicationHost Microsoft.ServiceFabric.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel</Arguments>
<WorkingFolder>CodePackage</WorkingFolder>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048" />
</ExeHost>
</EntryPoint>
</CodePackage>
<Resources>
<Endpoints>
<Endpoint Protocol="http" Name="WebTypeEndpoint" Type="Input" Port="5000" />
</Endpoints>
</Resources>
</ServiceManifest>
project.json:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework": "6.1.3",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.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.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "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.ServiceFabric.AspNet.Hosting": "1.0.0-rc1",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"Sportflash.Web.Core": "1.0.0-*",
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"angular-signalr-hub.TypeScript.DefinitelyTyped": "0.6.7",
"Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Globalization.CultureInfoCache": "1.0.0-rc1-final",
"Microsoft.Extensions.Localization.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Localization": "1.0.0-rc1-final",
"Microsoft.Extensions.Localization": "1.0.0-rc1-final",
"jquery.TypeScript.DefinitelyTyped": "2.8.8",
"signalr.TypeScript.DefinitelyTyped": "0.2.0",
"Newtonsoft.Json": "8.0.3",
"Microsoft.CodeAnalysis": "1.1.0-rc1-20151109-01"
},
"userSecretsId": "aspnet5-Sportflash.Web-f067f2f7-086e-4a52-88ea-a7317d1b11e8",
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"gen": "Microsoft.Extensions.CodeGeneration"
},
"frameworks": {
"dnx451": {
"dependencies": {
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components",
"PackageRoot"
],
"publishExclude": [
"node_modules",
"bower_components",
"PackageRoot",
"**.user",
"**.vspscc"
],
"scripts": {
"postrestore": [ "npm install", "bower install" ],
"prepublish": [ "npm install", "bower install" ]
}
}
Startup.cs:
public class Startup
{
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
I will suggest to explore this example on GitHub.
This example demonstrates how ASP.NET Core can be used in a communication listener of stateless/stateful services.
This example is updated to use dotnet cli.
There are 2 different branches dnx and dotnetcli. dnx branch can be used inside Visual Studio.
I did everything that was told [on OpenIddict getting started tutorial]:
I ran dnvm upgrade
I've added all given sources to Nuget.Config
Added "OpenIddict": "1.0.0-*" to project.json dependencies
This is what Visual Studio tells when I hover my mouse over underlined in red "OpenIddict" dependence in project.json:
The dependency OpenIddict 1.0.0-alpha2-0161 in project [...] does not support framework DNXCore, Version=v5.0
Cleaning project and restoring nuget packages doesn't help. What should I do to make it work?
EDIT:
project.json:
{
"userSecretsId": "[...]",
"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.Authentication.JwtBearer": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Identity": "3.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.CodeGenerators.Mvc": "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",
"Microsoft.Net.Http.Server": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"System.IdentityModel.Tokens": "5.0.0-rc1-211161024",
"OpenIddict": "1.0.0-*"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
Sadly, you can't use OpenIddict in an ASP.NET 5/Core RC1 application: you must use ASP.NET Core RC2, as mentioned in the getting started page.
If you want to migrate to RC2, you can take a look at the Mvc.Server sample: https://github.com/openiddict/openiddict-core/tree/dev/samples/Mvc.Server.
{
"buildOptions": {
"emitEntryPoint": true,
"warningsAsErrors": true,
"preserveCompilationContext": true,
"embed": {
"include": [ "Certificate.pfx" ]
},
"copyToOutput": {
"include": [
"wwwroot",
"Views",
"config.json",
"web.config"
]
}
},
"dependencies": {
"AspNet.Security.OAuth.GitHub": "1.0.0-alpha4-final",
"AspNet.Security.OAuth.Introspection": "1.0.0-alpha1-final",
"AspNet.Security.OAuth.Validation": "1.0.0-alpha1-final",
"Microsoft.AspNetCore.Authentication.Google": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Authentication.Twitter": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"OpenIddict": { "target": "project" }
},
"frameworks": {
"net451": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-rc2-24027"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002702" }
},
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
}
},
"scripts": {
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"config.json",
"web.config"
]
}
}
I have a PCL with this project.json:
{
"supports": {
"net46.app": {},
"uwp.10.0.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0",
"System.ServiceModel.Primitives": "4.0.0"
},
"frameworks": {
"dotnet": {
"imports": "portable-net452+win81"
}
}
}
When I add a reference to my asp.net 5 web app, the resulting web app's project.json looks like this:
{
"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.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"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"MyPcl": "1.0.0-*"
}
},
"dnxcore50": {
"dependencies": {
"MyPcl": "1.0.0-*"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Which from what I can tell should be correct, but it results in a couple of errors in the web app:
Predefined type 'System.Object' is not defined or imported MyWebApp.DNX 4.5.1 C:\source\MyWebAppStartup.cs
Predefined type 'System.Void' is not defined or imported MyWebApp.DNX 4.5.1 C:\source\MyWebApp\Startup.cs
Ive found 100 ways to fix this, none have worked, and Im just not getting it. Any help would be appreciated. (Im using VS2015)
EDIT: Restarting VS resolved those errors. Now there is only this error
Object reference not set to an instance of an object. MyWebApp C:\source\MyWebApp\DNX 1
Im trying to get remote IP address in Asp.net Vnext.
after i added this line in my code , the page stopped working in published IIS
server (no error appears , only white screen) :
var remoteIpAddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
also when i checked the result in local IIS-Express it gives me this :
this my project.json file :
{
"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.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",
"DataAccessComponents": "1.0.0-*",
"Utility": "1.0.0-*",
"AdModels": "1.0.0-*",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-rc1-final",
"Microsoft.Net.Http": "2.2.22",
"Newtonsoft.Json": "7.0.1",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final",
"System.Net.Http": "4.0.1-beta-23516",
"System.Net.Primitives": "4.0.11-beta-23516",
"System.Text.Encoding": "4.0.11-beta-23516",
"Microsoft.AspNet.WebApi.Client": "5.2.3",
"Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final",
"Microsoft.Dnx.Compilation.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Http.Features": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0",
"System.Net.Http.WebRequest": "4.0.0.0",
"System.Web": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Also im using normal IIS 8 for my project and im not gonna port this program to another OS.
should i change the "Web" Section in project json ? Like adding iis or something ?