小编Ram*_*yev的帖子

React Native:无法构造变压器:错误:无法创建长度超过 0x1fffffe8 个字符的字符串

听到的是错误的屏幕截图

包.json

{
  "name": "project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.12.0",
    "@react-native-community/clipboard": "^1.2.3",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/drawer": "^5.9.0",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.9.0",
    "@twotalltotems/react-native-otp-input": "^1.3.11",
    "jetifier": "^1.6.6",
    "react": "16.13.1",
    "react-native": "^0.63.2",
    "react-native-barcode-builder": "^2.0.0",
    "react-native-biometrics": "^2.1.4",
    "react-native-chart-kit": "^6.6.1",
    "react-native-gesture-handler": "^1.7.0",
    "react-native-image-picker": "^2.3.3",
    "react-native-localization": "^2.1.6",
    "react-native-paper": "^4.0.1",
    "react-native-reanimated": "^1.13.0",
    "react-native-safe-area-context": "^3.1.6",
    "react-native-screens": "^2.10.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.1.0",
    "react-native-swipe-list-view": "^3.2.3",
    "react-native-vector-icons": "^7.0.0"
  },
  "devDependencies": {
    "@babel/core": "7.11.4", …
Run Code Online (Sandbox Code Playgroud)

node.js react-native

16
推荐指数
3
解决办法
3万
查看次数

如何在 ASP.NET Core 3.1 中获取当前的 JsonSerializerOptions?

我使用 System.Text.Json 并在 Startup.cs 的 ConfigureServices 方法中设置 JsonSerializerOptions

 public void ConfigureServices(IServiceCollection services)
 { 
 ...
            services.AddControllers()
                    .AddJsonOptions(options =>
                    {
                        options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
                    });
 ...
 }
Run Code Online (Sandbox Code Playgroud)

现在我想在 CustomErrorHandlingMiddleware 中获取当前的 JsonSerializerOptions

public async Task InvokeAsync(HttpContext context)
{
      try
      {
          await _next(context);
      }
      catch (Exception exc)
      {
          var response = new SomeObject(); 
                
          var currentJsonSerializerOptions = ? //I want get CurrentJsonSerializerOptions here

          var result = System.Text.Json.JsonSerializer.Serialize(response, currentJsonSerializerOptions);

          context.Response.ContentType = "application/json";
          context.Response.StatusCode = 500;
          await context.Response.WriteAsync(result);
      }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现这个目标?谢谢。

c# system.text.json asp.net-core-3.1

9
推荐指数
1
解决办法
5275
查看次数

ASP.NET Core 3.1 中的 Session.SetString 方法抛出异常“IFeatureCollection 已被处理。对象名称:'Collection'。”

我有一个用 ASP.NET Core 3.1 编写的项目。

我需要在 Singleton 服务中将数据设置为 Session:

 _session.SetString("some key", "some value");
Run Code Online (Sandbox Code Playgroud)

我从 DI 注入了会话对象:

public OperatorService(ILogger<OperatorService> logger, 
                       ISession session,
                       IOptions<AppSettings> options)
{
     this._session = session; 
     this._logger = logger; 
     this._appSettings = options.Value;
}
Run Code Online (Sandbox Code Playgroud)

我调用我的方法如下:

public void ChangeOperatorStatus(StatusChangeRequest request)
{
     try
     {
         _session.SetString(request.Key, request.Value);
     }
     catch (Exception ex)
     {
          _logger.LogInformation($"Exception while changing status: {ex}"); 
     } 
} 
Run Code Online (Sandbox Code Playgroud)

但我得到以下异常:

IFeatureCollection has been disposed.\r\nObject name: 'Collection'. 
Run Code Online (Sandbox Code Playgroud)

我在 Startup.cs 的 ConfigureServices 方法中添加了一些代码:

services.AddHttpContextAccessor();

services.AddSession(options =>
{
    options.IdleTimeout = TimeSpan.FromMinutes(20);
    options.Cookie.HttpOnly = true;
})
.AddDistributedMemoryCache(); …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-core asp.net-core-3.1

8
推荐指数
1
解决办法
4143
查看次数

ASP.NET Core 与接口绑定嵌套配置

我有一些配置界面

public interface IAppConfig
{
    IFeatureConfiguration FeatureConfiguration { get; set; }
    IOtherConfiguration OtherConfiguration { get; set; }
}
public interface IFeatureConfiguration 
{
    string SettingFoo { get; set; }
}
public interface IOtherConfiguration 
{
    string SettingBar { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

和课程

public class AppConfig : IAppConfig
{
    public IFeatureConfiguration FeatureConfiguration { get; set; }
    public IOtherConfiguration OtherConfiguration { get; set; }
}
public class FeatureConfiguration : IFeatureConfiguration 
{
    public string SettingFoo { get; set; }
}
public class OtherConfiguration : …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

6
推荐指数
1
解决办法
2011
查看次数

ASP.NET MVC 基于角色的登录和重定向

我正在使用 ASP.NET MVC 生成的默认登录方法,并希望对其进行更改,以便它将根据用户的角色重定向到指定的视图。我已检查该用户是否具有该角色。我在 SignInStatus 成功块内进行了重定向,但没有成功。

User.IsInRole()在其他代码块中使用了并且工作正常。我认为执行 if 语句时用户尚未完全登录。我认为情况确实如此,但我不确定我可以实施什么解决办法。

下面是我的代码。

// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateCustomAntiForgeryTokenAttribute]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (!ModelState.IsValid)
    {
        return View(model);
    }

    // This doesn't count login failures towards account lockout
    // To enable password failures to trigger account lockout, change to shouldLockout: true
    var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
    switch (result)
    {
        case SignInStatus.Success:
            if (User.IsInRole("Customer"))
            {
                return RedirectToAction("Customer", "Home");
            }
            else if (User.IsInRole("Requestor"))
            {
                return …
Run Code Online (Sandbox Code Playgroud)

authentication asp.net-mvc

5
推荐指数
1
解决办法
8432
查看次数

如何在 imap-simple 中检索“已发送”邮箱

我在 Node.js 中使用imap-simple 。我想找回gmail发送的邮箱。我的代码如下:

 getSent(searchCriteria: string[], callBack: any) {
        imaps.connect(this.imapConfig).then(function (connection) {

            return connection.openBox('SENT').then(function () {
                var fetchOptions = {
                    bodies: ['HEADER', 'TEXT', ''],
                    markSeen: false
                };

                return connection.search(searchCriteria, fetchOptions).then(function (results) {

                    let mails = results.map(res => {
                        return {
                            part: res.parts.find(part => part.which === ''),
                            attributes: res.attributes
                        };
                    });

                    mails = [].concat(...mails);

                    mails = mails.map(mail => {
                        return new Promise((resolve, reject) => {

                            var id = mail.attributes.uid;
                            var idHeader = "Imap-Id: " + id + "\r\n";

                            simpleParser(idHeader …
Run Code Online (Sandbox Code Playgroud)

javascript imap node.js

4
推荐指数
1
解决办法
1866
查看次数

在 IIS 上部署 API 时不显示 Swagger UI

好吧,我将 Swagger 用于我的 API 文档,它在 localhost 中运行良好,当我将它托管在 IIS 上时,问题就开始了。出于某种原因,它不再起作用了

本地主机:

https://localhost:44381/swagger/index.html
Run Code Online (Sandbox Code Playgroud)

接口:

http://200.155.29.14/SimuladorFrete/Swagger/index.html
Run Code Online (Sandbox Code Playgroud)

当我在 ISS 中部署 Swagger 后尝试打开它时,我得到的只是一个空白页面和一个 500 内部服务器错误,这并没有说明异常。

这是我的配置方法(startup.cs)

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();

    }
    app.UseHttpsRedirection();

    app.UseRouting();

    app.UseAuthorization();

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
    });
    app.UseSwagger();
    app.UseStaticFiles();
    app.UseSwaggerUI(c =>
    {
        if (env.IsDevelopment())
        {
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1");
        }
        else
        {
            // To deploy on IIS
            c.SwaggerEndpoint("/SimulaFrete/swagger/v1/swagger.json", "Web API V1");
        }

    });
}
Run Code Online (Sandbox Code Playgroud)

这是我的 ConfigureServices 方法:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers().AddNewtonsoftJson();

    services.AddSwaggerGen(c =>
    { …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api swagger swashbuckle asp.net-core

1
推荐指数
2
解决办法
6969
查看次数