asp.net-core-mvc

MVC:- Integration of mvc6.grid

五迷三道 提交于 2019-12-07 18:45:02
问题 I want to integrate mvc6.grid, I followed the steps but getting error in view. Error " 'HtmlHelper< IEnumerable< SchemeMaster>>' does not contain a definition for 'Grid' ". Model:- public partial class SchemeMaster { public int SchemeID { get; set; } public string SchemeName { get; set; } public Nullable<int> Createdby { get; set; } public Nullable<System.DateTime> Createddate { get; set; } public string CompanyName { get; set; } public string city { get; set; } public Nullable<bool> Married

Custom Selective 404 Page in MVC6

佐手、 提交于 2019-12-07 18:09:53
问题 I am looking for help we can have a custom Error404 page in ASP.NET 5 MVC6. The closest I have come is to use app.UseStatusCodePagesWithReExecute("/Error/{0}"); in the Startup.cs Configure method. It works fine by calling the "/Error/404" action. I am looking on ways on how I can send a different 404 response in the event it is a missing JPG/PNG/GIF request. Any suggestion in the right direction would be of great help. 回答1: As an alternative to the custom middleware approach, you can use

ASP.NET Core MVC - Model Binding : Bind an interface model using the attribute [FromBody] (BodyModelBinder)

陌路散爱 提交于 2019-12-07 17:33:42
问题 I want to bind an interface model from my action method with a request that the content-type is application/json. I'm using the [FromBody] attribute in my action method. I tried to create a custom modelBinder derived from ComplexTypeModelBinder, by following this link: Custom Model Binding in Asp.net Core, 3: Model Binding Interfaces, but it doesn't work, my model is always null. I learned after that when you use the atribute [FromBody] the BodyModelBinder is called and internally is calling

ASP.NET Core Filters - ignore for defined methods

时光怂恿深爱的人放手 提交于 2019-12-07 16:49:44
问题 We implement a log information to our database. I will use a Filters (IActionFilter) functionality for it. I wrote the following class: public class ActionFilter: Attribute, IActionFilter { DateTime start; public void OnActionExecuting(ActionExecutingContext context) { start = DateTime.Now; } public void OnActionExecuted(ActionExecutedContext context) { DateTime end = DateTime.Now; double processTime = end.Subtract(start).TotalMilliseconds; ... some log actions } } Then I have added the

Returning String Result from Ajax Method

怎甘沉沦 提交于 2019-12-07 16:49:04
问题 I have a DoughnutChart chart and I would like to change the color of its parts regarding color hexa-codes saved in the database I used this Ajax method to get the color string by invoking an action method that returns JSON Result , getcolors: function getcolors(name) { return $.ajax({ url: "/api/ideas/getcolors", data: { name: name }, type: "GET", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data, textStatus, jqXHR) { // return data; }, error: function

Error in Service IUserStore being created in Identity Asp.net core 3 MVC

时光毁灭记忆、已成空白 提交于 2019-12-07 15:48:06
问题 Update See Update below. I have asked a previous stackoverflow question very recently, but I face an issue after implementing the suggested solutions from the following 2 places Identity model customization in ASP.NET Core and Custom storage providers for ASP.NET Core Identity. I am just not able to get the solution to work. I have implemented the extension of IdentityUser as recommended and the extension of IdentityRole . I have implemented IUserPasswordStore and IUserRoleStore and

dotnet exec needs a managed .dll or .exe extension while adding Entity Framework Core (1.1.0) Migrations

大城市里の小女人 提交于 2019-12-07 14:37:24
问题 Error Message: PM> Add-Migration InitialDatabase dotnet exec needs a managed .dll or .exe extension. The application specified was 'C:\Users\xxxxxx\documents\visual studio 2017\Projects\TheWorld\src\TheWorld\bin\Debug\netcoreapp1.0\TheWorld.runtimeconfig.json' Process finished with non-zero exit code PM> Visual Studio Version: 2017 RC Project Dependencies : Error Screenshot : 回答1: I had the same problem. The only thing I had to do is changing the Target Framework in the Project properties.

Entity Framework 6 not recognizing AddSqlServer()

喜你入骨 提交于 2019-12-07 14:34:05
问题 I am trying to use EF6 with VS2015 CTP and ASP.NET MVC 6. it is not recognizing the below mentioned code in startup.cs which I added when I was using EF7. public void ConfigureServices(IServiceCollection services) { services.AddEntityFramework(Configuration) .AddSqlServer() .AddDbContext<VNDBContext>(options => options.UseSqlServer(Configuration.Get("Data:VNDBContext:ConnectionString"))); services.AddMvc().Configure<MvcOptions>(options => { var jsonFormatter = (JsonOutputFormatter)options

How to turn on Roles in Asp.net Identity 3.0 and MVC 6?

会有一股神秘感。 提交于 2019-12-07 13:49:47
问题 I am not sure if I am missing something here. By Default User.IsInRole() does not work even if user DOES HAVE some roles. I don't have my own implementation of role stores. I am assuming that the default ones should work. Is there something special that I need to do in the Startup.cs to get the roles working? I'm using mvc 6 beta 2 default template. 回答1: The User.IsInRole() does not work if I add a role like this: await UserManager.AddToRoleAsync(user, "Admin"); But it does work if I do this:

ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking

隐身守侯 提交于 2019-12-07 13:40:11
问题 I have created a default ASP Net Core MVC web app with Individual User Accounts. I added a custom UserID INT field to the AspNetUsers table and linked this as a foreign key to all my other custom tables so I can track what users inserted/updated records in my database. I did this as I prefer using INT fields for primary keys. In this scenario everything is working fine. I am now thinking of using an external identity provider such as Azure Active Directory however I cannot work out how I