asp.net-core-mvc

ASP.NET Core: jQuery Error 404 for the online version of the project

試著忘記壹切 提交于 2020-01-05 09:04:16
问题 The problem: Recently I've been modifying my Javascripts references in my project since they were repeting in several views (between the _Layout and views) causing errors. At this moment there are no visible errors while working locally but once the project is online (thru Azure) the error 404: failed to load resource appears in the scripts section. Information: This is the current _Layout of the project: <!DOCTYPE html> <html> <head> <meta content="text/html" charset="utf-8" http-equiv=

How to use npm packages with ASP.NET CORE 2 in Visual Studio 2017?

倾然丶 夕夏残阳落幕 提交于 2020-01-05 07:27:42
问题 I added some npm packages to my ASP.NET Core 2 project in Visual Studio 2017. Now I want to use css and js files from these packages, but VS doesn't see them because node_modules folder is outside wwwroot. What is the common practice here, how to make Visual Studio working with node_modules? 回答1: The common practice is to bundle your web assets, and put only the compiled bundle into your wwwroot folder. Since Visual Studio 2015 we have multiple Taskrunners from the NPM World: Gulp Grunt With

How to use npm packages with ASP.NET CORE 2 in Visual Studio 2017?

旧街凉风 提交于 2020-01-05 07:26:51
问题 I added some npm packages to my ASP.NET Core 2 project in Visual Studio 2017. Now I want to use css and js files from these packages, but VS doesn't see them because node_modules folder is outside wwwroot. What is the common practice here, how to make Visual Studio working with node_modules? 回答1: The common practice is to bundle your web assets, and put only the compiled bundle into your wwwroot folder. Since Visual Studio 2015 we have multiple Taskrunners from the NPM World: Gulp Grunt With

How to inspect asp.net core methods?

狂风中的少年 提交于 2020-01-05 07:14:31
问题 I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository. https://github.com/aspnet/AspNetCore/ I am highly interested in this method. https://localhost:portnumber/Identity/Account/Login Q1: How to find this method in my project and is it possible to debug it? Q2: Why I dont see

How to inspect asp.net core methods?

别来无恙 提交于 2020-01-05 07:14:30
问题 I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository. https://github.com/aspnet/AspNetCore/ I am highly interested in this method. https://localhost:portnumber/Identity/Account/Login Q1: How to find this method in my project and is it possible to debug it? Q2: Why I dont see

User.Identity.IsAuthenticated = false after login successfully mvc core 3.0 with web api

狂风中的少年 提交于 2020-01-05 07:12:09
问题 this is image obvious the problem. my login function in api public async Task<object> Login([FromBody] LoginDto model) { var user = _context.Users.FirstOrDefault(x => x.Email == model.Email || x.UserName == model.Email); var result = await _signInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, false); var IsAuthenticate = User.Identity.IsAuthenticated; await _signInManager.SignInAsync(user, model.RememberMe); if (result.Succeeded) { var appUser = _userManager

Error CS0433 The type 'WebUtility' exists in two places

蹲街弑〆低调 提交于 2020-01-05 05:40:10
问题 I'm creating an asp.net core app using Visual Studio 2017. I'm trying to encode a URL component using web utility. var value = System.Net.WebUtility.UrlEncode("some text here"); When I include that in my code, I see the below error. I'm at a loss as to finding the issue. I see no project.json file. I have searched for anyplace where System.Runtime.Extensions are being included. I have the following packages installed: AspNetCore, AspNetCore.Mvc, AspNetCore.StaticFiles, .netCore.App, PaulMiami

dotnet core no overload method for UseInMemoryDatabase() takes 0 argument

雨燕双飞 提交于 2020-01-05 05:38:06
问题 I am trying dotnet core tutorial at https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc TodoContext.cs using Microsoft.EntityFrameworkCore; namespace TodoApi.Models { public class TodoContext : DbContext { public TodoContext(DbContextOptions<TodoContext> options) : base(options) { } public DbSet<TodoItem> TodoItems { get; set; } } } Startup.cs using ... using TodoApi.Models; using Microsoft.EntityFrameworkCore; namespace TodoApi { public class Startup { public Startup

How to pass a service from .net core di container to a new object created with automapper

佐手、 提交于 2020-01-05 04:16:30
问题 I'm facing a scenario where I need to inject a service from asp.net core DI container to the constructor of an object created using automapper. I don't know if this is the best practice but let me explain what I'm trying to accomplish. I've an asp.net core mvc controller that receives a model parameter, just a POCO, that model needs to be converted into a ViewModel class that contains some business logic, data access etc, in that class object I want to get some info from the injected service,

asp.net core mvc controller unit testing when using TryUpdateModel

淺唱寂寞╮ 提交于 2020-01-05 04:10:07
问题 In an asp.net core application, I have a pair of controller methods that respond to an Edit action. One for GET, which takes a string parameter for the entity id: public async Task<IActionResult> Edit(string id) and the other for receiving a POST of updated entity values: [HttpPost] [ActionName("Edit")] [ValidateAntiForgeryToken] public async Task<IActionResult> EditSave(string id) Inside the postable action method, I call var bindingSuccess = await TryUpdateModelAsync(vm); And that works