asp.net-core-2.0

.Net Core with Angular 4 : 404 error when I refresh the browser

自闭症网瘾萝莉.ら 提交于 2019-12-22 18:19:12
问题 I have built an angular 4 application with .Net core 2.0, visual studio 2017, and deployed to production server on IIS web server. The routing is working fine on localhost when refresh,but not working on live. I saw some answers in stackoverflow for IIS in web.config file. But I don't have web.config file under my project structure. can I add it manually or how can I fix it. <system.webServer> <rewrite> <rules> <rule name="Main Rule" stopProcessing="true"> <match url=".*" /> <conditions

identity server 4 windows authentication

柔情痞子 提交于 2019-12-22 17:54:30
问题 I have followed a combination of these three resources for getting started with Identity Server 4. IdentityServer4.Quickstart.UI 4_ImplicitFlowAuthenticationWithExternal Combined_AspNetIdentity_and_EntityFrameworkStorage The combination of the three were used in order to store users within the the database even from external providers. Also store Identity Server 4 configurations such as claims, roles, clients, and resources. My main issue right now is when running in IIS Express windows

identity server 4 windows authentication

和自甴很熟 提交于 2019-12-22 17:53:02
问题 I have followed a combination of these three resources for getting started with Identity Server 4. IdentityServer4.Quickstart.UI 4_ImplicitFlowAuthenticationWithExternal Combined_AspNetIdentity_and_EntityFrameworkStorage The combination of the three were used in order to store users within the the database even from external providers. Also store Identity Server 4 configurations such as claims, roles, clients, and resources. My main issue right now is when running in IIS Express windows

How to throw ForbiddenException in ASP.NET Core 2 Instead of using AccessDeniedPath

限于喜欢 提交于 2019-12-22 11:27:46
问题 I am working on an ASP.NET Core 2 web application. I am handling Access Denied page for [Authorize (roles OR policies)] pages. By default, Instead of showing the original URL and returning 403 status, ASP.NET Core 2.0 redirects the request to an AccessDenied page with status is 302 -> This is not what I want. Instead of redirecting AccessDenied page. I want ASP.NET Core throws my custom ForbiddenException exception so I can handle unauthorized accesses like I do for Unhandled exceptions. Here

How to set default datetime format for .net core 2.0 webapi

血红的双手。 提交于 2019-12-22 11:24:58
问题 Currently in my local. The API is expecting the same formart as in SQL Server database which is yyyy-mm-dd. However when i am deploying the application into production server. The API is expecting the datetime format as yyyy-dd-mm. Is there any way to configure my .net core web api to accept yyyy-mm-dd as default format in every enviroment? 回答1: 100% of the time, If I am using DateTime , I create an interface for it. It just makes life a lot easier when it's time for testing. I believe this

Issue with SignalR core and cross domain requests

余生颓废 提交于 2019-12-22 10:43:52
问题 We are using SignalR core with CORS cross domain requests. The client is unable to connect to server. 401 Unauthorized No Access-Control-Allow-Origin' header is present on the requested resource. Error: Failed to start the connection. Note we are using the most recent signalr core (alpha version for asp.net core 2.0). Please note within the same client app, i'm able to access CORS Web API methods. It's isolated to SignalR hub/client. We are using Windows authentication in IIS. Anonymous seems

How to avoid n+1 queries in EF Core 2.1?

浪尽此生 提交于 2019-12-22 06:59:44
问题 I'm using EF Core 2.1 preview which was supposed to reduce N+1 queries problem. I'm trying to make query, that selects Forum Threads with authors of posts: dbContext.ForumThreads .Include(t => t.Posts) .Take(n) .Select(t => new { t.Id, t.Title, PostAuhtors = t.Posts.Select(p => p.Author).Take(5) }).ToArray(); This produces n+1 queries: For each ForumThread it selects post authors The schema is simple: public class ForumThread { public Guid Id {get;set;} public string Title {get;set;} public

getting the request body inside HttpContext from a Middleware in asp.net core 2.0

一世执手 提交于 2019-12-22 05:11:32
问题 I am having a simple middleware which fetches the body of the request and store it in a string. It is reading fine the stream, but the issue is it wont call my controller which called just after I read the stream and throw the error A non-empty request body is required . Below is my code. public async Task Invoke(HttpContext httpContext) { var timer = Stopwatch.StartNew(); ReadBodyFromHttpContext(httpContext); await _next(httpContext); timer.Stop(); } private string ReadBodyFromHttpContext

Nuget restore fails for ASP.NET Core 2.0 project on build server

谁说胖子不能爱 提交于 2019-12-22 03:21:45
问题 I am trying to build an ASP.NET Core 2.0 application for .NET Framework 4.6.2 (not .NET Core) with TeamCity on Windows Server 2012R2. The following components are installed in the server: Microsoft .Net Core SDK - 2.0.0.0 Microsoft .Net Framework (4.5.2, 4.6, 4.6.2) Microsoft Build Tools (2013, 2015, 2017) Windows SDK 10.0 ... TeamCity uses nuget version 4.1 and the solution file to restore dependent packages (see full log below for details). Error: [22:57:51] [22:57:51]Errors in C:\path\to

post multi-select list to list of objects asp.net core 2

冷暖自知 提交于 2019-12-21 22:44:52
问题 I have two classes called User and Role. User is like this class User{ ... public List<Role> Roles; } and Role is like this class Role{ ... public int ID; public string Name; } now I have an action (Submit) public IActionResult Submit(User user){ ... } in my index.cshtml select is <select multiple="multiple" class="multi-select" id="my_multi_select1" asp-for="Roles" asp-items="ViewBag.Roles"></select> and ViewBag.Roles value is ViewBag.Roles= new SelectList(Role.SelectAll(), "Name", "Name");