我有一个有几个不同类的类,我将这些类中的信息发送给客户,但我不想将它们全部发送出去,所以有些是私有的,有些是[JsonObject(MemberSerialization.OptIn)]
旗帜等.
但是,现在我想在需要关闭服务器时每隔12个小时(我不想使用数据库)对所有这些对象进行备份,所以我想做的(如果可能的话)是强制JSON .Net Serializer转换对象和属于该对象的所有对象.
例如:
class Foo
{
public int Number;
private string name;
private PrivateObject po = new PrivateObject();
public string ToJSON()
{ /* Serialize my public field, my property and the object PrivateObject */ }
}
Run Code Online (Sandbox Code Playgroud)
我尝试了这段代码(即使它已经过时了)但它没有序列化与我的对象相关的对象:
Newtonsoft.Json.JsonSerializerSettings jss = new Newtonsoft.Json.JsonSerializerSettings();
Newtonsoft.Json.Serialization.DefaultContractResolver dcr = new Newtonsoft.Json.Serialization.DefaultContractResolver();
dcr.DefaultMembersSearchFlags |= System.Reflection.BindingFlags.NonPublic;
jss.ContractResolver = dcr;
return Newtonsoft.Json.JsonConvert.SerializeObject(this, jss);
Run Code Online (Sandbox Code Playgroud) 我尝试运行一个Blazor
应用程序。
Web.Server runs .NET Core 3.0
Web.Client runs .NET Standard 2.0
Web.Shared runs .NET Standard 2.0
Run Code Online (Sandbox Code Playgroud)
发布并上传应用程序后,IIS
我收到此错误:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Run Code Online (Sandbox Code Playgroud)
Event Viewer
包含此错误消息:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Run Code Online (Sandbox Code Playgroud)
当我运行dotnet --info
我可以看到,我都Microsoft.NetCore.App
和Microsoft.AspNetCore.App
包含版本3:PS C:\用户\ FooBar的> DOTNET --info .NET核心SDK(反映任何global.json):版本:3.0.100-preview6-012264提交:be3f0c1a03
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763 …
Run Code Online (Sandbox Code Playgroud) 我正在使用Corona SDK将数据发布到我的C#服务器:
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Accept-Language"] = "en-US"
local body = "color=red&size=small"
local params = {}
params.headers = headers
params.body = body
network.request( host .. "/UpdateHand", "POST", nwListener, params )
Run Code Online (Sandbox Code Playgroud)
我在服务器上收到一条消息:
Post["/UpdateHand"] = x =>
{
Console.WriteLine("Received ...");
return "Ok";
};
Run Code Online (Sandbox Code Playgroud)
但是当我检查数据时(当我在其上放置一个断点)时,我看不到我的数据所在的位置(即params.body或params.headers).我该如何提取这些信息?
我应该根据Corona上的文档正确发布它:http://docs.coronalabs.com/daily/api/library/network/request.html
我们内部使用的ASP.NET核心应用程序在办公时间使用,批处理应该每天早上3点处理,HangFire
如下所示:
RecurringJob.AddOrUpdate(
() => MyBatch(),
"0 0 3 1/1 *");
Run Code Online (Sandbox Code Playgroud)
问题是应用程序池进入休眠状态,如果站点未手动启动(通常访问网站),则不处理批处理.
我用来修改设置的一些来源:
应用程序池总共使用了7个应用程序(在应该处理批处理的夜晚都处于非活动状态).使用的应用程序池使用.NET CLR Version
2.0
.我正在使用IIS版本10.0.17134.1.
如何使应用程序池保持活动状态,以便每天早上定期调用批处理?
我正在开展一个他们要求我使用Visual Studio 2013的项目,所以我下载但是我仍然无法打开解决方案.这是错误消息:
Unsupported
This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them.
For more information on enabling these project types or otherwise migrating your assets, please see the details in the "Migration Report" displayed after clicking OK.
- {name}.OutlookAddIn, "{path}\{name}.OutlookAddIn.csproj"
- {name}.Installer, "{path}\{name}.Installer.vdproj"
No changes required
These projects can be opened in Visual Studio 2013, Visual Studio 2012, and …
Run Code Online (Sandbox Code Playgroud) 我按照本教程:https://medium.com/@st.mas29/microsoft-blazor-web-api-with-jwt-authentication-part-1-f33a44abab9d
我下载了这个例子:https://github.com/StuwiiDev/DotnetCoreJwtAuthentication/tree/Part2
我可以看到令牌已创建,但我不明白它是如何保存或应该保存在客户端,因为每次我访问它时SampleDataController
,它都有Authorize
标签,它返回401.
使用Postman调用和添加令牌时,它可以正常工作.
我对用户进行身份验证缺少什么?不Microsoft.AspNetCore.Authentication.JwtBearer
处理客户端部分(存储令牌)?
当我Buyin
从ASP.NET MVC控制器创建一个对象的响应时,(return Json(response, JsonRequestBehavior.AllowGet);
看起来像这样:
"Buyin": {
"Id": 95,
"PlayerSessionId": 88,
"PlayerId": 45,
"PlayerName": "Alan",
"Amount": 888,
"BuyinType": "Credits",
"Description": null,
"Authorized": true,
"SignPath": "~/Signs/Buyins\\95.png",
"Payment": null,
"CreationDate": "/Date(1477242738042)/"
},
Run Code Online (Sandbox Code Playgroud)
如果我在Epoch Converter上转换它,我会得到这个时间:GMT: Sun, 23 Oct 2016 17:12:18.042 GMT
在数据库中查看存储的日期时间似乎是正确的:
95 NULL 1 1 2016-10-23 17:12:18.043
Run Code Online (Sandbox Code Playgroud)
发送响应时,Kind
将设置为UTC
.
现在我调用一个控制器来获取我的所有数据,并且所有日期都有几个小时添加到它:
{
"Id": 95,
"PlayerSessionId": 88,
"PlayerId": 45,
"PlayerName": "Alan",
"Amount": 888,
"BuyinType": "Credits",
"Description": null,
"Authorized": true,
"SignPath": "~/Signs/Buyins\\95.png",
"Payment": null,
"CreationDate": "/Date(1477267938043)/" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的解决方案之一上安装 EntityFramefork 但Package Manager Console
无法识别Enable-Migrations
.
PM> Enable-Migrations
Enable-Migrations : The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a pa
th was included, verify that the path is correct and try again.
At line:1 char:1
+ Enable-Migrations
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
}, …
Run Code Online (Sandbox Code Playgroud)