asp.net-core

Newtonsoft JsonConvert datetime format as JavascriptSerializer

爷,独闯天下 提交于 2021-02-11 12:28:44
问题 I'm using .NET Core and want to serialize a date into the same format as the System.Web.Script.JavascriptSerializer, but using Newtonsoft jsonconverter instead (or something else compatible with .NET Core since the JavascriptSerializer is .NET framework). Example: DateTime result1; var dt1 = DateTime.TryParse("12.06.2012 10:34:00",CultureInfo.GetCultureInfo("DA-dk"), DateTimeStyles.None, out result1); JsonConvert.Serialize(result1); This does NOT return a format like this that I need: "/Date

Storing custom class property like String via OnModelCreating of DBContext .Net Core

孤人 提交于 2021-02-11 12:22:22
问题 I have two classes in .Net Core The class Owner namespace CustomStoreDatabase.Models { public class Owner { public string OwnerId { get; set; } public DateTime MinDateTime { get; set; } public DateTime MaxDateTime { get; set; } public TimeSpan Interval { get; set; }//store like a double public Ownership Ownership { get; set; } //store like a JSON String in the db } } And the class Ownership namespace CustomStoreDatabase.Models { public class Ownership { public string OwnershipId { get; set; }

Global customization of error responses from .bet core 3.1 webapi

落爺英雄遲暮 提交于 2021-02-11 12:19:53
问题 I'm using app.UseExceptionHandler("/error"); to customize the output of any unhandled exceptions. However, validation errors use the framework ( ApiController ) and automatically return a default formatted error. I see that I can overwrite this using InvalidModelStateResponseFactory but is there a way to have one global location to handle all of these? I understand that one is for 500 responses and the other is 400 responses but I'd like to consolidate if possible. 回答1: If you just display

Where is the dist directory in VS when running Angular template?

偶尔善良 提交于 2021-02-11 12:07:48
问题 We're successfully running a new Angular application created and hosted under VS2017 in the very default template (Core + Angular). We promise that we made no changes to it. Seriously. While it's running, we expected that a dist directory would be present in wwwroot (or at the very least somewhere within the solution structure). It is not. We've googled the issue trusting there was a gazillion programmers before us asking the very same thing. Turns out... not that many. And the blogs we've

Where is the dist directory in VS when running Angular template?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 12:07:24
问题 We're successfully running a new Angular application created and hosted under VS2017 in the very default template (Core + Angular). We promise that we made no changes to it. Seriously. While it's running, we expected that a dist directory would be present in wwwroot (or at the very least somewhere within the solution structure). It is not. We've googled the issue trusting there was a gazillion programmers before us asking the very same thing. Turns out... not that many. And the blogs we've

Where is the dist directory in VS when running Angular template?

允我心安 提交于 2021-02-11 12:05:10
问题 We're successfully running a new Angular application created and hosted under VS2017 in the very default template (Core + Angular). We promise that we made no changes to it. Seriously. While it's running, we expected that a dist directory would be present in wwwroot (or at the very least somewhere within the solution structure). It is not. We've googled the issue trusting there was a gazillion programmers before us asking the very same thing. Turns out... not that many. And the blogs we've

Authorize Attribute not working with JWT Access Token in ASP.Net Core

核能气质少年 提交于 2021-02-11 10:26:08
问题 Trying to setup JWT with Ast.Net Core app and somehow when I use the [Authorize] attribute on the method it shows Bearer error="invalid_token" Not sure what I am missing here. AppSettings: "Jwt": { "Key": "ThisisaKeyforAPIAccess", "Issuer": "TestSite.com" } Method to generate Access Token: var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"])); var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken

How to launch watch mode in Visual Studio 2017 ASP.NET Core 1.1.1

强颜欢笑 提交于 2021-02-11 09:19:45
问题 I'm trying to run my web application in watch mode referring to How to watch for file changes "dotnet watch" with Visual Studio ASP.NET Core but in newer version (core 1.1.1) I can't find launchSettings.json file, so where put settings? I installed Microsoft.DotNet.Watcher.Tools but I don't have a button "watch" in Visual Studio. 回答1: You can find the launchSettings.json in the Solution Explorer under the menu Properties. There you can add the settings for your "watch" profile. You can add

How to launch watch mode in Visual Studio 2017 ASP.NET Core 1.1.1

筅森魡賤 提交于 2021-02-11 09:16:48
问题 I'm trying to run my web application in watch mode referring to How to watch for file changes "dotnet watch" with Visual Studio ASP.NET Core but in newer version (core 1.1.1) I can't find launchSettings.json file, so where put settings? I installed Microsoft.DotNet.Watcher.Tools but I don't have a button "watch" in Visual Studio. 回答1: You can find the launchSettings.json in the Solution Explorer under the menu Properties. There you can add the settings for your "watch" profile. You can add

How to remove cookies asp.net core authorization

﹥>﹥吖頭↗ 提交于 2021-02-11 08:10:47
问题 asp.net core for example I deleted the user but he has cookies authorization, that is, he can not press the logout button and continue to use with his account how to fix the situation 回答1: This is a general problem of claims based authentication when removing access for users. Due to how it is designed, the database is not accessed on every request to verify the access. Instead, the cryptographically signed cookie is considered to be the source of truth. So when the access is removed in the