asp.net-core-mvc

in asp.net 5 is it possible to store and read custom files in approot instead of wwwroot?

拟墨画扇 提交于 2019-12-09 09:25:31
问题 when you deploy an asp.net5/mvc6 app there is the wwwroot folder where web assets like css, js, images belong, and there is approot folder where packages and source code belong. It seems that classes in the Microsoft.Framework.Configuration namespace for example must be able to read files from below approot since that is where config.json files would live. What I want to know is, is it possible to store and read custom files of my own in approot? and if so how? For example I'm not using

How to remove all objects (reset ) from IMemoryCache in ASP.NET core

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 07:50:06
问题 I can find a remove method to remove an object from IMemoryCache by its key. Is there a way to reset the whole cache and remove all objects? Edit: How to clear MemoryCache? Dispose method provided in the link gives me an exception in asp.net 5. ObjectDisposedException: Cannot access a disposed object. Object name: 'Microsoft.Extensions.Caching.Memory.MemoryCache'. 回答1: https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory Section Cache dependencies Using a

Entity Framework Core 1.0 DbContext not scoped to http request

我只是一个虾纸丫 提交于 2019-12-09 06:44:35
问题 I understood by watching this video with Rowan Miller https://channel9.msdn.com/Series/Whats-New-with-ASPNET-5/06 (at minute 22) that the way of configuring Entity Framework Core (previously known as EF7) into an ASP.NET Core 1.0 app (previously known as ASP.NET 5) in Startup.cs is as follows: public void ConfigureServices(IServiceCollection services) { //Entity Framework 7 scoped per request?? services.AddEntityFramework() .AddSqlServer() .AddDbContext<MyDbContext>(options => { options

Build: Cannot find name Promise - Visual Studio 2015 w/ MVC6 and Angular 2

好久不见. 提交于 2019-12-09 05:44:59
问题 First of all: I've checked these: https://github.com/angular/angular/issues/7052 https://github.com/angular/angular/issues/4902 Typescript cannot find name 'Promise' despite using ECMAScript 6 how to use es6-promises with typescript? Visual Studio Code: Cannot find name angular? How to get rid of Angular2 / TypeScript errors on Cannot find map, Promise ... when targeting -es5 And many many many more. Been banging my head for 2 days now. And yes: I have referenced in my boot.ts file (or

mvc6 unauthorized results in redirect instead

非 Y 不嫁゛ 提交于 2019-12-09 05:27:56
问题 I have been trying to prevent the redirect when I return an NotAuthorized IActionResult from a Controller, but regardless of my attempts, NotAuthorized gets translated to a Redirect. I have tried what is mentioned here (same issue, using older beta framework, I use 1.0.0-rc1-final). I do not have the Notifications namespace (has been removed in rc1-final). This is my Login Controller: [HttpPost] [AllowAnonymous] public async Task<IActionResult> Login(LoginViewModel model, string returnUrl =

Unit testing routing in ASP.NET Core 1.0 (ex MVC 6)

房东的猫 提交于 2019-12-09 05:02:24
问题 As the architecture of ASP.NET Core 1.0 (ex MVC 6 / ASP.NET 5.0) changed significantly, how would one go about unit testing the routing? As an example, I like the libraries such as this one (as for <= MVC 5): https://github.com/AnthonySteele/MvcRouteTester Something down the lines of fluent extension methods: routes.ShouldMap("/").To<HomeController>(x => x.Index()); 回答1: Alright... I did ping the ASP.NET team and asked them how they proceeded to do their tests. Short answer You can't unit

How to Use AspNet.Identity core in My Sql database

我们两清 提交于 2019-12-09 04:50:22
问题 I am developing one application using asp dot net core 2 using MySql database .Please help me How can i use Asp Net Identity in MySqlDatabase . 回答1: I had to do this for a client. And I did in an application with ASP.NET Core 1.0, but for curiosity I also tried for an application in .NET Core 2.0. What I did was first install the Entity Framework MySQL package from https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/ using package manager console. After that I changed in the

Identity Server 4 (2.0) not reading Asp.Net Core Identity cookies

梦想与她 提交于 2019-12-09 04:22:27
I am trying to use Asp .Net Identity Core with Identity Server 4 . I can see in the logs (Ids) that the user is logged in properly. info: Xena.IdentityServer.Controllers.AccountController[0] User logged in. My login controller then sends the user over to my Manage controller. [Route("[controller]/[action]")] [Authorize] //[Authorize(AuthenticationSchemes = "Identity.Application")] public class ManageController : Controller { [HttpGet] public async Task<IActionResult> Index(ManageMessageId? message = null) { ..... } } The User never arrives as the login is then lost for some reason. info:

Adding custom claim not working in asp.net core identity

蹲街弑〆低调 提交于 2019-12-09 02:04:05
问题 I have created CustomClaimType to store user id : public static class CustomClaimTypes { public const string UserId = "UserId"; } When user login, I set it: var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, doc_session.ufname + " " + doc_session.ulname)); claims.Add(new Claim(CustomClaimTypes.UserId, doc_session.isci_id.Value.ToString())); ClaimsIdentity userIdentity = new ClaimsIdentity(claims,"Identity.Application"); ClaimsPrincipal principal = new ClaimsPrincipal

Angular2 http post not passing the json object to MVC 6 controller action

久未见 提交于 2019-12-09 01:09:21
I am working on an angular 2 application using asp.net MVC6. Angular2 Http post method calls the controller action and works properly when there is no parameter/properties, but when i add a parameter to the controller action, The expected JSON mapping is not happening while trying to call action with the parameter values. Debugging the action shows null value to the parameter. I tested with all the solutions provided in this discussion , but still i am getting the null value for the parameter. debug screenshot Here is my code 1.Controller action [HttpPost] public IActionResult addNewUser