asp.net-core-mvc

MVC ICollection<IFormFile> ValidationState always set to Skipped

ぃ、小莉子 提交于 2019-12-06 18:35:08
问题 As part of an ASP.NET Core MVC 1.0 project, I have a ViewModel with an ICollection<> property. I need to validate that this collection contains one or more items. My custom validation attribute doesn't get executed. In my instance it holds multiple file attachments from a multipart/form-data form. I have decorated the property in the ViewModel with a custom validation attribute: [RequiredCollection] public ICollection<IFormFile> Attachments { get; set; } Below is the custom attribute class.

Model binding in ASP.NET Core to map underscores to title case property names

不羁岁月 提交于 2019-12-06 18:33:31
问题 I have a model class that I want to bind a query string to in my ASP.NET MVC Core (RC2) application. I need to support underscores in query string keys to confirm to OAuth specs, but I want to work with title case property names in my application. My model class looks like this: class OauthParameters { public string ClientId {get; set;} public string ResponseType {get; set;} public string RedirectUri {get; set;} } so I'd like to bind query strings like client_id , response_type and redirect

NormalizedUserName VS Username in DotNet Core

喜欢而已 提交于 2019-12-06 17:12:45
问题 I'm trying to create a custom implementation of IUserLoginStore for MongoDB and I noticed when using UserManager<ApplicationUser> with the method var userResult = await _userManager.CreateAsync(user); it goes through the implementation of GetUserNameAsync FindByNameAsync SetNormalizedUserNameAsync GetUserIdAsync I would like to clarify two questions: what's the purpose of having a NormalizedUsername and a UserName? the only difference that I could notice id that the normalizedUserName is in

Execute non-query procedure not working asp.net core

被刻印的时光 ゝ 提交于 2019-12-06 15:53:30
问题 I want to execute a stored procedure which returns three values (Email, Name, CompanyID) and get one parameter (CompanyID) but it's not working. I have created a class with these properties and a stored procedure which returns the data. By it is showing DatabaseFacade error. My code is: List<MyClass> AppUser = new List<MyClass>(); //Class with three properties SqlParameter param1 = new SqlParameter("@CompanyID", CompanyID); AppUser = _context.Database.SqlQuery<CC>("GetUserAndRolesForCompany",

How to find the .dnx location in mac which have .NET core alone (without mono)

删除回忆录丶 提交于 2019-12-06 15:17:47
I have installed .NET Core alone (without mono) in my mac book. But i unable to find the .dnx location in my machine. I tried the following command ~/.dnx , but there no folder is available, i tried with another machine with have mono, in there, such folder is available. Really i don't know why difference in .dnx location between mono and .NET core installed machine ? I need to place a custom package in .dnx location for testing purpose instead hosting in nuget.org. How to achieve this scenario in .NET core installed MacBook ? -Guru Try to run dnvm list -Detailed to also show the location of

Changing Identity 3.0 table names in ASP.NET Core MVC6 not working

寵の児 提交于 2019-12-06 14:56:19
This same question was asked and has not been answered after 12 days... I have looked at this which uses "ToTable" as an update to the question. I have looked at this which appears to be out of date. I want to change the table names of the identity 3.0 tables - ASP.NET Core. So far, using the "ToTable" option's (No. 2 above) update, I have managed to corrupt my lockfile and have as a result corrupted the project. The third option is out of date. I created a vanilla project - no changes just created via VS2015 with identity 3.0 I then tried this: protected override void OnModelCreating

Not able to use XUnit for unit tests in ASP.NET VNext and Visual Studio 2015 RC

冷暖自知 提交于 2019-12-06 13:31:50
I created a a Visual Studio 2015 RC solution as follows: Project global.json Source MvcProject MvcProject.Test MvcProject.Test is a class library where I created a Test. The global.json file has the following: { "projects": [ "Source" ], "sdk": { "version": "1.0.0-beta4" } } And project.json in MvcProject.Test is: { "compilationOptions": { "warningsAsErrors": true }, "dependencies": { "Microsoft.AspNet.Mvc": "6.0.0-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "commands": { "test": "xunit.runner.aspnet" }, "frameworks": { "dnx451": { "dependencies": { "Moq": "4.2.1506.2016" } } } } I then

MVC:- Integration of mvc6.grid

巧了我就是萌 提交于 2019-12-06 13:14:05
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 { get; set; } } View :- @model IEnumerable< MVC6_Grid_with_filters.Models.SchemeMaster> @using

Access appsettings.json file setting from the class library project

不打扰是莪最后的温柔 提交于 2019-12-06 12:54:20
I know how to set appsettings.json file on web project.But can you tell me how to access that from the class library project ? I can configure it as shown below on the web project.Then how can I access that values from the class library project ? Is that possible ? public class MyConfig { public string ApplicationName { get; set; } public int Version { get; set; } } public class Startup { public IConfigurationRoot Configuration { get; set; } public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json",

Routing in SPA with ASP.NET MVC 6 and AngularJS

蓝咒 提交于 2019-12-06 12:06:03
问题 I have a sample MVC6 single page app with one view in which I want to load 2 Angular partials using ngRoute. You can have a look at it at GitHub There are 3 URLs in the app: localhost - Index.cshtml localhost/games - Index.cshtml with Angular's gamelist.html partial localhost/games/2 - Index.cshtml with Angular's game.html partial The routes config is the following: MVC: app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}"); routes.MapRoute(