asp.net-core-2.2

Asp.Net core Tempdata and redirecttoaction not working

自闭症网瘾萝莉.ら 提交于 2021-02-20 05:50:24
问题 I have a method in my basecontroller class that adds data to tempdata to display pop-up messages. protected void AddPopupMessage(SeverityLevels severityLevel, string title, string message) { var newPopupMessage = new PopupMessage() { SeverityLevel = severityLevel, Title = title, Message = message }; _popupMessages.Add(newPopupMessage); TempData["PopupMessages"] = _popupMessages; } If the action returns a view, this works fine. If the action is calling a redirectotoaction I get the following

Why is ClaimTypes.NameIdentifier not mapping to 'sub'?

冷暖自知 提交于 2021-02-18 22:07:25
问题 Using ASP.NET Core 2.2 and Identity Server 4 I have the following controller: [HttpGet("posts"), Authorize] public async Task<IActionResult> GetPosts() { var authenticated = this.User.Identity.IsAuthenticated; var claims = this.User.Identities.FirstOrDefault().Claims; var id = this.User.FindFirstValue(ClaimTypes.NameIdentifier); } I get all the claims but id is null ... I checked all values in claims and I have a 'sub' claim with value 1. Why is ClaimTypes.NameIdentifier not mapping to 'sub'?

Aspnet core 2.2 default route changed to “~/index.html” after installing Swashbuckle.AspNetCore package

ぃ、小莉子 提交于 2021-02-11 09:39:39
问题 After installing the Swashbuckle.AspNetCore in my Asp.net Core (MVC) application the default route is override with "index.html" page. Where ever I used "~/" now is redirecting my application to "~/index.html" instead of default MVC route. How i can fix this? 回答1: I had encountered this issue after setting the route prefix of swagger to root i.e. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "LMW Valuer API V1"); c.RoutePrefix = string.Empty; }); Even after removing

Asp.NET Core 2.2: Swagger endpoint specific security definition

可紊 提交于 2021-02-08 05:37:22
问题 I am using Swashbuckle.AspNetCore 5.0.0-rc2 in one of my .Net Core 2.2 REST projects. Within my project I am serving two different apis which are logically connected to each other. Today, I managed to seperate my swagger documentations to have one swagger endpoint per api containing only the corresponding api controllers. I managed to do this by adding a specified group name to the api explorer settings of the controllers: [Authorize(AuthenticationSchemes = JwtBearerDefaults

Fill a DropDownList based on the selected value from another DropDownList

为君一笑 提交于 2021-01-29 12:00:34
问题 I was trying to fill a DropDownList based on the value from another DropDownList in MVC .NET Core 2.2. <div class="form-group row"> <label class="col-sm-2 col-form-label">Type :</label> <div class="col-sm-10"> <select asp-for="SelectedType" asp-items="@(new SelectList(Model.TypeList, "TypeName", "TypeDescription"))" class="custom-select custom-select-sm"> </select> </div> </div> public class Type { public string TypeName { get; set; } public string TypeDescription { get; set; } } I'm not

How to make a middleware that can call database to check user claims to authorize a user in asp.net core 2.2

会有一股神秘感。 提交于 2021-01-29 05:30:58
问题 What is the best practice to make a middleware or a proper way to implement middleware in asp.net core 2.2. My Scenario is I have a web api build in asp.net core 2.2 and I implement authorization in my controller something like this [Authorize(Policy = "UserDelete")] UserDelete is a user claim my problem is i have many user claim can user have, more or less up to 20 claims if I save this claims in JWT it can cause large size of JWT all i want to do is to call claims or create a middleware

ASP.NET Core API ISO8601 not parsed in local time when suffix is 'Z'

强颜欢笑 提交于 2021-01-28 10:17:51
问题 Scenario: I have a REST-API that takes a POST-Request. As Body-Data there is passed a Datetime in ISO8601 Format. { "validate": "2019-12-02T23:00:00Z", "configuration": {}, "sortId": 1 } With Modelbinding in MVC the Datetime gets parsed automaticly. The variable should be in the local timezone of the api-server. In this case Europe/Berlin. I would expect the time to be (refering to the example) to be on 2019-12-03:00:00:00. But this is not the case. It is still one hour off. But when i post

ASP.NET Core API ISO8601 not parsed in local time when suffix is 'Z'

旧街凉风 提交于 2021-01-28 10:16:15
问题 Scenario: I have a REST-API that takes a POST-Request. As Body-Data there is passed a Datetime in ISO8601 Format. { "validate": "2019-12-02T23:00:00Z", "configuration": {}, "sortId": 1 } With Modelbinding in MVC the Datetime gets parsed automaticly. The variable should be in the local timezone of the api-server. In this case Europe/Berlin. I would expect the time to be (refering to the example) to be on 2019-12-03:00:00:00. But this is not the case. It is still one hour off. But when i post

Asp .Net Core Download Report from SSRS

不问归期 提交于 2021-01-05 10:46:19
问题 I have been trying hard to get a report from SSRS but seems like it is not supported in .Net Core. So I would like to know if is there a way to just download the report on browser in Asp .Net Core with parameters? All i need is to download it, no need to preview it with report view since there is no compatibility for this. User clicks a button and parameters are sent through controller or razor page and just need a way to get report and download on browser 回答1: According to microsoft

Asp .Net Core Download Report from SSRS

匆匆过客 提交于 2021-01-05 10:45:36
问题 I have been trying hard to get a report from SSRS but seems like it is not supported in .Net Core. So I would like to know if is there a way to just download the report on browser in Asp .Net Core with parameters? All i need is to download it, no need to preview it with report view since there is no compatibility for this. User clicks a button and parameters are sent through controller or razor page and just need a way to get report and download on browser 回答1: According to microsoft