asp.net-core-mvc

Exception on opening existing project after ugrading to ASP.NET MVC6 beta7

余生长醉 提交于 2019-12-13 13:26:55
问题 I'm using Visual Studio 2015 Community Edition and updated my existing ASP.NET MVC6 application to beta7. Now I'm not able to open the project anymore. Visual Studio crashes with the following Exception: 08.09.2015 20:23:12 Crippling System.AggregateException: One or more errors occurred. ---> Microsoft.Assumes+InternalErrorException: The specified default content type (Default) is not defined in the project item schema. at Microsoft.Assumes.Fail(String message, Boolean showAssert) at

.Net MVC Core Policy based authorization with JWT

梦想与她 提交于 2019-12-13 12:44:04
问题 I'm trying to setup my authorization policy with a jwt based token for my apis. I have two controllers, used by separate apis. I need to make sure a user can only access the ones that he/she is allowed to use. So I figured I'd go with policy based authorization [Authorize(Policy = "API1")] [Route("api1/endpoint")] public class API1Controller : Controller { // my actions for api 1 } [Authorize(Policy = "API2")] [Route("api2/endpoint")] public class API2Controller : Controller { // my actions

asp.net core error: ArgumentException: Keyword not supported: 'sslmode'

让人想犯罪 __ 提交于 2019-12-13 08:59:45
问题 I am currently trying out Asp.net core with MySQL and I am also new to Asp.net core MVC. The first time I tried to fetch data I got the following error MySqlException: The host localhost does not support SSL connections. After researched i found out that i needed to add SslMode=none at the connection string so i added it like this "server=127.0.0.1;database=test;uid=root;password=;SslMode=none;" it solved the error but now when I try to register a user with the default user authentication

Configuring Nunit with ASP.NET MVC Core 1.0

青春壹個敷衍的年華 提交于 2019-12-13 08:24:38
问题 I wanted to configure NUnit for my ASP.NET Core 1.0 project. I have tried following : http://www.alteridem.net/2015/11/04/testing-net-core-using-nunit-3/ , but it's there for console applications. If I try to attach a new project (class library) to my solution and then try to reference my original project - it gives me reference error. Here is what worked for me: I attached another web app project, dedicated to writing tests, to my original project, as opposed to the console library project.

ASP.Net Core 2.1 MVC SelectList in View is not getting populated

﹥>﹥吖頭↗ 提交于 2019-12-13 08:06:40
问题 I am working on an ASPNet Core 2.1 MVC website and I am trying to get a select list to populate with a list of Companies (value = Id, text = CompanyName). I can see that the data exists in the List in the ViewModel but no matter what I try, I can't get the data to show in the dropdown list in the view. I am following the first variation of the SelectList recommendation from this SO post Here is my EditSite ViewModel class public class EditSite { public int Id { get; set; } [Required]

Moq, unit test using xUnit framework and testing a function returning an object

江枫思渺然 提交于 2019-12-13 07:48:36
问题 I have a repository public class StudentsPersonalDetailsRepository : IStudentPersonalDetailsRepository { private readonly StudentManagementSystemEntities _studentsDbContext; private readonly ILogger _logger; public StudentsPersonalDetailsRepository(StudentManagementSystemEntities context, ILogger<IStudentPersonalDetailsRepository> logger) { _studentsDbContext = context; _logger = logger; } public IQueryable<StudentPersonalDetails> StudentPersonalDetails => _studentsDbContext

Context keyword doesn't get recognized in ASP.net 5 MVC Controller for use with Sessions

限于喜欢 提交于 2019-12-13 07:40:01
问题 I am using ASP.net 5 Beta 8. I want to make use of Sessions however Context keyword is not being understood. In my packages.json "Microsoft.AspNet.Http": "1.0.0-beta8", "Microsoft.AspNet.Session": "1.0.0-beta8", In my ConfigureServices of Startup.cs // Add MVC services to the services container. services.AddMvc(); //Session Support services.AddSession(); services.AddCaching(); In Configure of Startup.cs //Session app.UseSession(); // Add MVC to the request pipeline. app.UseMvc(routes => {

How to ignore empty values when passing a ViewModel (object) via Ajax to an MVC controller

可紊 提交于 2019-12-13 07:03:55
问题 In the following view I'm passing an Object (ViewModel) to controller. It works fine if user enters all the values in the form. The sample Requested URL with querystring generated via LINQ query is as follows: Request URL:http://localhost:50507/OrdCtrl/OrdAction?OrdYear=2016&OrderNumber=CE123&OrderName=testOrder&hasOrdered=true&_=1489509308855 But if the user skips entering one value in the search form, say, orderName the user gets the expected error: NullReferenceException: Object reference

Docker unable to resolve .net standard class libraries, on deploying .net core app to Docker

前提是你 提交于 2019-12-13 07:03:51
问题 I am deploying .net core app to Docker. My docker file is as follows, which is added in my .net core application: FROM microsoft/dotnet:1.1-sdk-projectjson COPY . /app WORKDIR /app RUN ["dotnet", "restore"] RUN ["dotnet", "build"] EXPOSE 5000/tcp ENV ASPNETCORE_URLS http://*:5000 ENTRYPOINT ["dotnet", "run"] Its not able to resolve .net standard class libraries, which are added to my .net core application. My project structure is as follows: Core folder -Logging.Interfaces .net std project

ASP.NET Core Jwt implement signinmanager claims

天大地大妈咪最大 提交于 2019-12-13 05:33:47
问题 I have implemented Jwt as a way to authenticate my user. However, I am stuck on how I can do certain things on my application with regards to roles. Currently my Jwt Token contains the users email, phone , id and a list of roles that they have. What I do with that token is like this: [TypeFilter(typeof(ValidateRolesFilter), Arguments = new object[] { ApplicationGlobals.ApplicationSecretKey, RoleGlobals.SystemAdministrator })] public IActionResult Index() { return View(); } My Typefilter