asp.net-core-mvc

ASP.Net 5 project referencing old class library

无人久伴 提交于 2019-12-24 02:10:50
问题 I was trying repository pattern with ASP.Net 5 project and service project. I referenced my " .Service" class library project into my " .Web" project but something went wrong with the reference. I removed all referenced to other libraries, even removed my " .Service" and " .Web" projects and added new empty ones but the newly created " .Web" project still referencing the old version of deleted " .Service" project. " .Web" > ASP.Net 5 project. " .Service" > .Net Framework 4.5.1 class library

need to verify angular4 from angular2 in visual studio 2017

感情迁移 提交于 2019-12-24 01:39:13
问题 I have upgraded my source from Angularjs2 to Angularjs4. I am using Visual studio 2017 and ASP.NET MVC Core. I want to verify now either i am using the updated version (4) or previous one (2). here is my package.json { "name": "angular-quickstart", "version": "1.0.0", "description": "QuickStart package.json from the documentation, supplemented with testing support", "scripts": { "build": "tsc -p src/", "build:watch": "tsc -p src/ -w", "build:e2e": "tsc -p e2e/", "serve": "lite-server -c=bs

User.Identity.Name returns null in ASP.NET Core MVC application

吃可爱长大的小学妹 提交于 2019-12-24 01:38:12
问题 Please check the code below. This is a controller of my ASP.NET Core 2.1 MVC application. Problem is that I am already using cookie authenticated user, but the User.Identity.Name returns null. How can I get my current auth user on .NET Core then? [HttpPost] public IActionResult AddMainMenu(MainMenuItems mainMenuItems) { string userEmail = User.Identity.Name; return Json("success"); } Thanks in advance. 回答1: Just use it- var val = User.FindFirst(ClaimTypes.Email).Value; If your claim

how can I install package to the wwwroot in mvc core 2

别等时光非礼了梦想. 提交于 2019-12-24 01:18:57
问题 Recently I Installed the VS 2017 Which Contains Asp.net mvc core 2 but there is a very confusion problems there! that is how can i Install a new package into the wwwroot so: _ Im using bower but supporting is end of and can not find out bower.json in the project>> new item after config it using npm . I installed it using npm but still can not find( .bowerrc file under bower.json.) to set the directory: So-called valid document _with gulp and grunt : end of supporting gulp too and can not find

Templating in ASP.Net Core

試著忘記壹切 提交于 2019-12-24 00:52:13
问题 I have a problem creating a "sub"-template in asp.net core . The idea is to define a complete html-bootstrap-block in a template file and call it in another parent/master cshtml file. ViewModel Person (filled in the controller) namespace RazorTemplating.Models.HomeViewModels { public class Person { [Required] [MinLength(2)] public string Firstname { get; set; } [Required] [MinLength(2)] public string Lastname { get; set; } [MaxLength(3)] public int Age { get; set; } public Group MainGroup {

How to rewrite a file before publish based on build configuration?

时光毁灭记忆、已成空白 提交于 2019-12-24 00:43:44
问题 I have a new asp.net V5 application that is really just a static angular site and I'm trying to do the equivalent of web.config transforms. My app.js file has a constant defined that is the serviceUrl which points to the url of our api (not in the same site) I've used gulp-replace and created tasks for each of our build targets that successfully replace the single string that needs to be replaced. The problem I'm having is that I need to be able to change that service url based on the build

Managing user authenticated state on manual URL navigation

心不动则不痛 提交于 2019-12-24 00:33:52
问题 I'm using Angular2 with ASP.NET Core MVC and managing manual URL navigation works fine, the server is loading my Home view with Angular2 successfully. On user authentication, I'm setting up a session variable like this : HttpHelper.HttpContext.Session.SetString("isLoggedIn", true.ToString() ); What I want is that after the user is in the application, if somewhat he wants to load a specific route by manually navigating to it, I want my service to call my ASP Controller to check if the user

MVC 6 VNext how to set HtmlFieldPrefix?

此生再无相见时 提交于 2019-12-23 23:50:43
问题 My view is divided into partial views. Hence, at the time of submission my model isn't reconstructed correctly. The page view displays employee data, where Employee.Contactinfo is the model of _contactInfo partial view, which again has a partial view _phoneInfo to render phone info having model Employee.ContactInfo.PhoneInfo. Now the problem is with the name of properties. Employee.ContactInfo.PhoneInfo.Contact1 at the time of rendering has name "Contact1", hence at the time of submission the

Changing default action doesn't work for ASP.NET Core 2

Deadly 提交于 2019-12-23 22:50:16
问题 On latest ASP.NET MVC CORE 2 default template, i am trying to change default action by modifying controller and action as below. I am expecting to see login page as default but i am having 404 http error. What I am doing wrong ? You can verify this issue on default ASP.NET CORE 2 MVC project. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Account}/{action=Login}/{id?}"); }); } 回答1: If you look at the AccountController class, you'll see it's decorated with a

Cannot get the UserManager class

末鹿安然 提交于 2019-12-23 19:21:17
问题 What I'm trying to do is to add a new admin user and assign it with the admin role. So.. I went to the Startup.cs class in Configure method and wrote the following code: var context = app.ApplicationServices.GetService<ApplicationDbContext>(); // Getting required parameters in order to get the user manager var userStore = new UserStore<ApplicationUser>(context); // Finally! get the user manager! var userManager = new UserManager<ApplicationUser>(userStore); However, I get the following error