asp.net-core-1.0

ASP.NET Core Response.End()?

谁说我不能喝 提交于 2020-01-23 04:55:16
问题 I am trying to write a piece of middleware to keep certain client routes from being processed on the server. I looked at a lot of custom middleware classes that would short-circuit the response with context.Response.End(); I do not see the End() method in intellisense. How can I terminate the response and stop executing the http pipeline? Thanks in advance! public class IgnoreClientRoutes { private readonly RequestDelegate _next; private List<string> _baseRoutes; //base routes correcpond to

How to read connection string in .NET Core?

牧云@^-^@ 提交于 2020-01-17 18:24:32
问题 I want to read just a connection string from a configuration file and for this add a file with the name "appsettings.json" to my project and add this content on it: { "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet- WebApplica71d622;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } On ASP.NET I used this: var temp

How to get Action and Controller name in ASP.Net Core MVC app?

孤者浪人 提交于 2020-01-13 16:24:06
问题 How to get Action and Controller names in ASP.Net MVC Core RC1 Application in Startup.cs ? I want to create a middleware and log the information (I want to Log detailed response to my Database, so I need Action and Controller info.) after following code in configure method of startup.cs - app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=User}/{action=Index}/{id?}"); }); //Want to get Action and controller names here.. 回答1: You'll want to inject the

'IServiceCollection' does not contain a definition for 'AddSession'

我与影子孤独终老i 提交于 2020-01-12 14:03:14
问题 I am getting an error while adding 'AddSession' in ASP.Net Core 1.1 using VS2017. 'IServiceCollection' does not contain a definition for 'AddSession' and no extension method 'AddSession' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) .csproj <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <PropertyGroup> <PackageTargetFallback>$

Using SignalR in ASP.NET Core 1.0

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-12 09:55:32
问题 We have an ASP.NET Core 1.0 RC1 application and we want to incorporate SignalR in it. However, SignalR is not yet a part of ASP.NET Core 1.0. Is there a way to still incorporate SignalR in our existing app or will we have to look into some other web sockets library such as socket.io? 回答1: Although SignalR 3 won't be a part of the 1.0 release of ASP.NET Core, you can still use SignalR in an ASP.NET Core web app project. In fact, check out this SignalR project on the official "aspnet" account

Using SignalR in ASP.NET Core 1.0

╄→гoц情女王★ 提交于 2020-01-12 09:51:26
问题 We have an ASP.NET Core 1.0 RC1 application and we want to incorporate SignalR in it. However, SignalR is not yet a part of ASP.NET Core 1.0. Is there a way to still incorporate SignalR in our existing app or will we have to look into some other web sockets library such as socket.io? 回答1: Although SignalR 3 won't be a part of the 1.0 release of ASP.NET Core, you can still use SignalR in an ASP.NET Core web app project. In fact, check out this SignalR project on the official "aspnet" account

Post a List<Interface> .net core 1.0

本秂侑毒 提交于 2020-01-12 08:58:29
问题 I'm building a dynamic form creator in .net core. A "form" will consist of many different form elements. So the form model will look something like this: public class FormModel { public string FormName {get;set;} public List<IElements> Elements{get;set;} } I have classes for TextBoxElement , TextAreaElement , CheckBoxElement that all implement the IElemets interface. And I have EditorTemplates for each element. The code to render the form works great. Though posting the form does not work

How to reference a specific version of NetStandard in project.json?

岁酱吖の 提交于 2020-01-07 03:44:28
问题 I am struggling to figure out how to force the npm ( Nuget Package Manager ) to resolve a specific version of the NetStandard1.X platform. I am trying to use Serilog but the version of .NetStandard it supports is v1.3. Is there any way to force this behavior in the project.json file via some command or switch or option. { "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.6.0", "Serilog": "2.2.1" }, "frameworks": { "netstandard1.3": { "imports": "dnxcore50", "dependencies": { }

How to access Asp.net Core DI Container from Class

孤者浪人 提交于 2020-01-04 04:09:08
问题 I am learning IoC & DI with Asp.net core. I have setup my dbcontext and other classes to be injected into my controllers. Currently my startup.cs looks like this: // Add framework services. services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity<ApplicationUser, IdentityRole>(options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 5; options.Password

.NET Core SDK Installer failed to install on windows 2012 R2 Standard

北城余情 提交于 2020-01-03 10:22:30
问题 I setting up my build server for CI using Jenkins. I am trying to install .NET Core SDK from https://www.microsoft.com/net/download However i tried executing downloaded DotNetCore.1.0.1-SDK.1.0.0.Preview2-003131-x64.exe i get unspecified error and here is complete log [07E8:0FE4][2016-09-19T12:09:36]i001: Burn v3.10.2.2516, Windows v6.3 (Build 9600: Service Pack 0), path: C:\Users\CODESC~1\AppData\Local\Temp\3\{0D7DA4AD-993A-4038-A544-14369A3FAF40}\.cr\DotNetCore.1.0.1-SDK.1.0.0.Preview2