问题标签 [aspnetcore-environment]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
80 浏览

c# - c# mvc aspnet.core async Task, RedirectToAciton 不工作

我正在使用 MVC aspnetcore dotnetcore 6.0

我使用 LoginController 进行授权。当它成功时,我想将用户重定向到 HomeController。但是 RedirectToAction 不起作用。我的代码在这里:

我的 Ajax 代码在这里:

我重复。我想在成功时重定向此代码。我尝试了许多我找到的解决方案,但也没有奏效。请帮忙。

0 投票
1 回答
74 浏览

c# - How to add a custom JSON file into IConfiguration based on a setting?

I am working on ASP.NET Core 6.0 WebAPI and I need to get data from a CRM system (Sales Logix) using Sage SData API. We have different CRM environments (Production, Staging, Development) and I want to be able to connect (or test) any environment from my WebAPI project.

For that to work, I would like to add a configuration key (to indicate a particular CRM environment) either in appsettings.json (or launchsetting.json). For example when setting is "crmEnvironment": "Development", I want to include a custom json file, named crm-dev.json. Similarly for "crmEnvironment": "Staging", I want to include crm-staging.json.

Each custom json file ideally contains the CRM Url, Username and Password.

Please tell me how can I conditionally add json config files as mentioned above, or is there any better approach of achieving similar results, considering security in mind. Best if I could have custom config files encrypted without having to shift away from the standards, just like we did for Web.Config files by inheriting ProtectedConfigurationProvider.

My questions is similar to How can I add a custom JSON file into IConfiguration?. But since Program.cs no longer uses the Main() method, I am wondering what would be the correct way to add custom json config files.

0 投票
1 回答
18 浏览

asp.net-core - 在应用程序启动时覆盖 aspnetcore appsettings.json 键值以进行集成测试

我正在编写一些针对在 docker 上运行的 SQL Server 实例运行的 aspnetcore 集成测试。我计划使用 xUnit 集合并在不同的端口上为特定的测试集合启动一个单独的 SQL Server 容器实例。所以多个 SQL Server 实例在不同的端口上运行。我创建了一个单独的appsettings.testing.json文件,将在测试host开始时加载。此设置 json 文件具有测试host开始进行测试时将用于连接的连接字符串。

TestDb有没有办法让我在开始测试时覆盖 key 的值host?与启动主机之前一样,我在特定端口上启动 SQL 容器,并希望host使用修改后的连接字符串,该字符串将包含port并连接到它。

我一直在检查文档,但无法理解是否有办法在运行时执行此操作?

0 投票
1 回答
41 浏览

docker - aspnetcore docker 容器上的开发证书

我是 Docker 新手,由于缺少 ssl 证书,我在 docker 中运行我的应用程序时遇到了麻烦。如何使用开发证书在具有非开发环境的 docker 中运行 aspnetcore 应用程序?

我有以下Dockerfile由 Visual Studio 生成:

当我使用默认设置(开发)从 Visual Studio 运行它时,它连接 Docker 并且一切运行良好。appsettings.docker.json但是,我想使用不同的 appsettings 文件appsettings.development.json(因此我设置了ASPNETCORE_ENVIRONMENT=Docker. 这引起了我的痛苦,因为我突然感到InvalidOperationException

基于这个答案,我发现 dotnet 在环境变量为Development. 对于不同的环境,如何解决这个问题?

我确实尝试dotnet dev-certs https在 Dockerfile 中使用该命令,但是,构建失败说映像中没有 sdk,因此不知道该命令。

0 投票
0 回答
19 浏览

c# - 超时调用长时间运行的 AWS Lambda aspnetcore

我有一个长时间运行的 lambda(有时 10 多分钟),我以这种方式调用它

我在不到 1000 秒(或 15 分钟)后从 InvokeAsync 行收到异常

异常:{ ClassName:System.Threading.Tasks.TaskCanceledException 消息:操作被取消。Data:null InnerException:{ ClassName:System.IO.IOException 消息:无法从传输连接读取数据:操作已取消。数据:空 InnerException:{ 类名:System.Net.Sockets.SocketException 消息:操作已取消

据我了解,当调用代码超时时,lambda 仍然继续其功能。我在 linux 的 docker aspnetcore 2.2 上运行。我应该设置任何其他默认超时吗?我可以看到 AWS sdk 正在使用 httpconnection 类,但我无权访问它的参数。有任何想法吗?