asp.net-core-mvc

Error on first build after downloading project from ASP Net Boiler Plate with ASP.Net Core 1.x Multi Page Web Application

喜你入骨 提交于 2020-01-05 03:48:05
问题 I am using visual studio 2017. I just download project from asp net boiler plate and open it in vs 17. When i rebuild the solution i got the big list of 370 errors. Few are listed below due to the content limits. Severity Code Description Project File Line Suppression State Error Package Microsoft.AspNetCore.Server.Kestrel 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore.Server.Kestrel 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0

Microsoft LocalReport (rdl) in ASP.NET Core MVC App

与世无争的帅哥 提交于 2020-01-04 07:28:08
问题 I am running a project with ASP.NET Core (2.1) MVC. In our company we do have a lot of work done with SQL Report Builder (rdlc and rdl files). Therefore we wanted to use a "one the fly" mechanism to generate PDF Files with the ReportBuilder technology in the asp.net core mvc webapp. I tried the same nuget packages we are using in .net Framework (asp.net API and desktop app) but they are not working. The packages I tried are: Microsoft.ReportingServices.ReportViewerControl.Winforms Microsoft

Injected HttpContext is always null

两盒软妹~` 提交于 2020-01-04 06:32:27
问题 This is honestly mindblowing, I can't get it to work. The context is always null, wherever it is injected... Do I have to add an instance of the context in Startup.cs? If Yes, how? Originating calls services.AddTransient<SessionService>(); Toast.Configure(app.ApplicationServices.GetRequiredService<SessionService>()); _session.Set("foo", "bar"); Toast Class public class Toast { private static SessionService _session; public static void Configure(SessionService sessionService) { _session =

ASP.NET Core Model Bind Collection of Unknown Length

六眼飞鱼酱① 提交于 2020-01-04 05:48:06
问题 I'm trying to work out how to model bind a collection to a model property within asp.net core. I understand that the way this can be done is to include fields as so: <input type="hidden" asp-for="items[0].Id" /> <input type="hidden" asp-for="items[0].Name" /> <input type="hidden" asp-for="items[1].Id" /> <input type="hidden" asp-for="items[1].Name" /> However what do you do if you want to allow the user to add additional items and/or remove others. In this case I am adding these items client

HTTP Error 310 ERR_TOO_MANY_REDIRECTS with RequireHttpsAttribute ASP.NET Core

喜欢而已 提交于 2020-01-04 04:39:29
问题 I'm building an application on ASP.NET core using MVC. I'm also using the Identity and Entity 7 framework in my application. I'm running the application on Microsoft Azure which should come with a HTTPS certificate. I'm enabling HTTPS in my Startup.cs using this code services.AddMvc(options => { #if !DEBUG options.Filters.Add(new RequireHttpsAttribute()); #endif }); My problem is that when I visit the web app I get a 310 HTTP ERR_TOO_MANY_REDIRECTS response. I already tried to clear my

File Path for PersistKeysToFileSystem on shared server

南楼画角 提交于 2020-01-04 04:08:07
问题 I'm trying to make my keys persist for users that log in. As I'm currently using shared hosting for the website, I've decided to use the file system to store the keyring. So the code looks like this: services.AddDataProtection() .PersistKeysToFileSystem(new DirectoryInfo("")) .SetApplicationName("MyWebsite") .SetDefaultKeyLifetime(TimeSpan.FromDays(90)) .ProtectKeysWithCertificate(cert); However, what I'm not really understanding is where I should hold these keys, and what would be the path I

Is there a better way than using an IAsyncActionFilter to authorize if user is in role or user id is in database for specific record

时光总嘲笑我的痴心妄想 提交于 2020-01-04 03:04:30
问题 Requirement: There are some controller methods which only can be called if: 1. User has role "TaskAdmin" OR 2. User is responsible for the database object which will be modified within the controller method (There is just a column with an user id to compare). The records in this datatable can change and are not "hardcoded". I know 2 possibilities to solve this problem: Create 2 methods. One with the attribute [Authorize(Roles = "TaskAdmin")] and one where it will be checked if the user is

How to extend ComplexTypeModelBinder

﹥>﹥吖頭↗ 提交于 2020-01-03 20:59:28
问题 I need to customize model binding for a particular class Foo that involves extending the normal binding logic with some additional post-processing (e.g., conditionally set null collection fields to an empty collection). I want to add this logic to model binding so that the results are available to action filters, etc. The most direct approach would be to derive from ComplexTypeModelBinder and override BindModelAsync . However, that method is unfortunately not virtual. Composition is the next

Register all the services at once using Default DI Container from ASP.NET 5 similar to Autofac

两盒软妹~` 提交于 2020-01-03 14:28:15
问题 With ASP.NET 5, there's already a DI shipped as default and it looks interesting. I have been using Autofac with MVC 5 which has the option to register all the assembly at once. Here is a sample code that register all the classes that ends with "Service" in Autofac. // Autofac Configuration for API var builder = new ContainerBuilder(); builder.RegisterModule(new ServiceModule()); ... ... builder.RegisterAssemblyTypes(Assembly.Load("IMS.Service")) .Where(t => t.Name.EndsWith("Service"))

Register all the services at once using Default DI Container from ASP.NET 5 similar to Autofac

梦想的初衷 提交于 2020-01-03 14:28:08
问题 With ASP.NET 5, there's already a DI shipped as default and it looks interesting. I have been using Autofac with MVC 5 which has the option to register all the assembly at once. Here is a sample code that register all the classes that ends with "Service" in Autofac. // Autofac Configuration for API var builder = new ContainerBuilder(); builder.RegisterModule(new ServiceModule()); ... ... builder.RegisterAssemblyTypes(Assembly.Load("IMS.Service")) .Where(t => t.Name.EndsWith("Service"))