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
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
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>
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 created a brand new ASP.NET Web API project from scratch. I selected an ASP.NET v5 blank Template and added nothing. My default project.json file looked like so:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
I then went to the NuGET package installer and added Microsoft.AspNet.WebApi and straight away I am presented with errors in the compiler:
I am finding this is occurring for a lot of packages I am trying to install (even the Microsoft.AspNet.WebApi.HelpPage package gives me the same errors). I am also trying to add DbModelBuilder to my classes which throws similar results (which makes me think something is corrupt somewhere):
My updated project.json file now looks like this:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.WebApi": "5.2.3"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Data.Entity": "4.0.0.0"
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
As I am setting this up a a brand new project, I am a little confused as to what I am doing wrong or if my installation of Visual Studio is messed up. It's making it impossible to follow any tutorials online due to all the errors I'm faced with.
Any help would be greatly appreciated.
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 ?