asp.net-core-2.2

Hosting multiple product APIs in single ASP.NET Core WebAPI Service

别说谁变了你拦得住时间么 提交于 2019-12-23 01:38:28
问题 I am designing an ASP.NET Core based Web API, which needs to support multiple variants of my product, let's say based on a license or the variety which it was installed. Instead of going for multiple services for each type of product, I thought of a single service which houses/hosts multiple Endpoints or URLs. I will make this configurable in the appsettings.json at the time of installation. I am aware of the UseUrls on creating the WebHost, but can I bind the specific URL in a set of URLs to

ASP.NET Core url rewrite only domain

六眼飞鱼酱① 提交于 2019-12-22 18:37:11
问题 I am trying to change my old domain to new one and I have huge data on my website. I need to change only my domain by url rewriting. When I request: www.myolddomain.net/article/seo-friendly-url-for-this-article I need to have a permanent (301) redirect to: www.mynewdomain.com/article/seo-friendly-url-for-this-article How ca I do this in asp.net core? 回答1: Have you considered URL Rewriting Middleware? It's pretty simple. Drop a IISUrlRewrite.xml file in the root of your application folder.

ASP.NET Core url rewrite only domain

北慕城南 提交于 2019-12-22 18:37:08
问题 I am trying to change my old domain to new one and I have huge data on my website. I need to change only my domain by url rewriting. When I request: www.myolddomain.net/article/seo-friendly-url-for-this-article I need to have a permanent (301) redirect to: www.mynewdomain.com/article/seo-friendly-url-for-this-article How ca I do this in asp.net core? 回答1: Have you considered URL Rewriting Middleware? It's pretty simple. Drop a IISUrlRewrite.xml file in the root of your application folder.

Link tag helper not working in asp.net core 2.2

☆樱花仙子☆ 提交于 2019-12-22 17:45:33
问题 My link tag helpers are no longer working properly after migrating to asp.net core 2.2. <a class="btn btn-outline-primary" asp-controller="MyController" asp-action="MyAction" asp-route-id="@Id">Link</a> This works fine when I set the compatibility version to 2.1, but produces an empty href when set to compatibility version 2.2. <a class="btn btn-outline-primary" href="">Link</a> I followed the steps Migrate from ASP.NET Core 2.1 to 2.2 .SetCompatibilityVersion(CompatibilityVersion.Version_2_1

Get ErrorMessage from Response in Netcore 2.2 Web API

十年热恋 提交于 2019-12-22 11:35:48
问题 I call Register method with empty username and password. So I received this result: { "errors": { "Password": [ "The Password field is required.", "Password length is between 4 and 8." ], "Username": [ "The Username field is required." ] }, "title": "One or more validation errors occurred.", "status": 400, "traceId": "0HLJIO56EGJEV:00000001" } My Dto: public class UserForRegisterDto { [Required] public string Username { get; set; } [Required] [StringLength(8, MinimumLength = 4, ErrorMessage =

ASP.NET Core Route attributes available in entire controller class

北城余情 提交于 2019-12-20 03:45:08
问题 Is there a way to make attributes specified in the route available in the whole class? For instance, consider this Controller: [Route("api/store/{storeId}/[controller]")] public class BookController { [HttpGet("{id:int:min(1)}")] public async Task<IActionResult> GetBookById(int storeId, int id) { } } And this request: /api/store/4/book/1 Inside the GetBookById method, the storeId variable is correctly populated with 4 and the id variable with 1. However, instead of having to pass the storeId

HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure after upgrading to ASP.NET Core 2.2

蹲街弑〆低调 提交于 2019-12-18 12:05:24
问题 After upgrading my project to ASP.NET Core 2.2, I tried to run the application (locally of course) and the browser displayed an error message like in the below screenshot. no more errors notified by visual studio error explorer. I don't know what's happen. 回答1: In my case, I upgraded some nuget packages to net core 2.2, but I did not have the net core 2.2 sdk installed, so I went to net core website to download the latest sdk or runtime package, and then I did a net stop was /y and then a net

.NET Core MVC Page Not Refreshing After Changes

天大地大妈咪最大 提交于 2019-12-17 23:37:31
问题 I'm building a .NET Core MVC on the latest version 2.2. I have a problem when I make changes to the CSHTML file and refresh the page, my changes are not reflected in the browser. I have to restart the project in order to see my changes. This has been happening for a while now so I'm not exactly sure what change caused this issue. I've tried using the chrome's "Empty Cache and Hard Reload" as well as other browsers to no avail. This happens on Windows and Mac using both Visual Studio for Mac

Insert a modal razor page in the navbar. How to do it?

旧巷老猫 提交于 2019-12-13 03:04:34
问题 I'm building a new website and one of the requirements is to have the login form be a modal window. I'm trying to include it in the top navigation bar and it's only being rendered if the user is not logged in. How can I add this modal window with it's own model inside the top navbar? Are there any alternatives? If I delete the model and let an empty modal everything works perfectly but when I add it again it doesn't work, because the model of the page (in this case the index page) is a

Get Azure AD Groups Before Building Authorization Policies

为君一笑 提交于 2019-12-11 19:45:07
问题 We're developing an application that uses a back-end built on .Net Core 2.2 Web API. Most of our controllers merely require the [Authorize] attribute with no policy specified. However, some endpoints are going to require the user to be in a particular Azure AD Security Group. For those cases, I implemented policies like this in the Startup.cs file: var name = "PolicyNameIndicatingGroup"; var id = Guid.NewGuid; // Actually, this is set to the object ID of the group in AD. services