新的...
我看到一些问题提供了上述问题的解决方案,但这不是减速器而是简单的功能.
奇怪的是,我在另一个调用和检索文件中的结构几乎完全相同,在这种情况下,它是一个令牌并且可以正常工作.在上面的例子中我几乎遵循相同的模式,但是当我在这种情况下运行程序时,它告诉我我所调用的不是函数.
好的,所以我在这里调用函数,包括该函数文件的import语句.
import { saveSelectData, confirmSelectDataExistance } from '../selectData/localStorageDropDowns'
....
//selectData download if nothing is local storage.
const testSelectDataExistance = confirmSelectDataExistance()
if (testSelectDataExistance) {
....
Run Code Online (Sandbox Code Playgroud)
..这里是confirmSelectDataExistance
上面引用的代码块:
export const confirmSelectDataExistance = () => {
const companyStateShortNameJson = localStorage.getItem(COMPANYSTATESHORTNAME)
const statesJson = localStorage.getItem(STATES)
const suburbLocationsJson = localStorage.getItem(LOCATIONS)
if (companyStateShortNameJson || statesJson || suburbLocationsJson) {
console.log('something exists in localstorage')
return true
}
console.log('nothing in localstorage')
return null
}
Run Code Online (Sandbox Code Playgroud)
它很简单,真的测试看看是否有任何东西localStorage
.
现在,正如我所说,我在这方面是全新的.我可能没有添加足够的信息.让我知道.正如我所说,我有一个相同的模式来检索一个令牌,它的工作完美.但是,这会抛出此错误.
Uncaught TypeError: (0 , _localStorageDropDowns.confirmSelectDataExistance) is not …
Run Code Online (Sandbox Code Playgroud) 我在 redux-form 文档中遵循了这个建议,它表明使用“FormSection”使主表单由许多组件组成是有利的。
完成后,我有一个客户端表单,其中嵌入了一个地址组件,如下所示:
<FormSection name="Address">
<Address />
</FormSection>
Run Code Online (Sandbox Code Playgroud)
有用。
但是,当我想根据 redux 表单文档中的此示例从 state 设置主表单的初始值时,主表单会填充,但 FormSection 中的 Address 组件不会。
我在客户端组件底部使用此代码连接到状态:
let ClientForm2 = connect(
(state, ownProps) => ({
initialValues: state.editClient,
enableReinitialize: true
}),
{ reducer }
)(ClientForm);
Run Code Online (Sandbox Code Playgroud)
你如何用来自主窗体的状态的初始值填充你的 FormSections?
没有关于如何用初始数据填充表单部分的信息......
我想为与使用它的项目不同的类库中的第二个和后续数据库创建迁移。有皱纹。我永远不会知道连接字符串,直到用户登录并且我可以从目录数据库 (saas) 中获取它。
对于目录数据库,我使用了这个站点的解决方案。很好 - 这个数据库在 appsettings.json 中有它的连接字符串,并且可以使用依赖注入。
客户端数据库都将使用相同的迁移完全相同。我的问题是,我不知道如何从包管理器控制台创建这个初始迁移..
我确实尝试运行这个:
dotnet ef migrations add INITIAL --context APIcontext -s ../Jobsledger.API
Run Code Online (Sandbox Code Playgroud)
它给了我以下错误:
尚未为此 DbContext 配置数据库提供程序。
我所期望的。
鉴于在不同的类库中运行迁移的 CodingBlast 解决方案(以上)需要一个我没有的连接,并且需要在启动时注册数据库连接......
..并且鉴于此迁移将由要创建的每个用户数据库使用,我该如何创建它,当然如何使用它?
我一直在关注这个关于嵌入式资源的小教程。它由 Derek Comartin 编写,处理将嵌入资源添加到 .csproj 文件的简单操作。
美好的。按照他的指示做了,但是我在资源流中得到了空值。有几个问题没有在属性等中将您的资源设置为“嵌入资源”,但我做到了所有这些。
以下是资源属性:
我的解决方案有很多项目组成,包括主项目或启动项目。我想用作嵌入式资源的资源或 JSON 文件位于 Initialisation 项目中,该项目是一个 DotNet Core 库项目,而不是启动项目。
我遵循有关使用以下方法查找名称等的建议:
var resourceNames = assembly.GetManifestResourceNames();
Run Code Online (Sandbox Code Playgroud)
这表明它甚至不可用,因此我得到了资源流的“空”。
这是我访问嵌入资源的代码。
public void CATALOGInitialiseSuburbs(CATALOGContext context)
{
var assembly = Assembly.GetEntryAssembly();
var resourceNames = assembly.GetManifestResourceNames();
var resourceStream = assembly.GetManifestResourceStream("EmbeddedResource.SUBURB.Initialisations.SuburbJSON.australianSuburbs.json");
using (var reader = new StreamReader(resourceStream, Encoding.UTF8))
{
var list = reader.ReadToEndAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
这是具有嵌入资源的项目的 csproj 文件。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon />
<Win32Resource />
</PropertyGroup>
<ItemGroup>
<None Remove="SUBURB.Initialisations\SuburbJSON\australianSuburbs2019-08.json" />
<None Remove="SUBURB.Initialisations\SuburbJSON\australian_postcodes 2019.csv" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SUBURB.Initialisations\SuburbJSON\australianSuburbs2019-08.json" …
Run Code Online (Sandbox Code Playgroud) 我正在 .net core 5.0 中开发。(Sam Xu 有一个关于迁移到 dotnet core 5 的教程)
我已经回到了 Visual Studio 中最简单的 API 项目的绝对最低限度。
今年早些时候,我在我的项目中进行了这项工作,它在 .net core 5.0 上运行。请参阅上面的教程。
在这个项目中,我创建了一个新项目。然后我去NuGet获取包“Microsoft.AspNet.OData”版本7.4.1
然后我将以下内容添加到启动文件中。
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddCors();
services.AddControllers();
services.AddOData(); //THIS ONE
}
Run Code Online (Sandbox Code Playgroud)
我添加了“services.AddOData”并抛出了错误,
错误 CS1061“IServiceCollection”不包含“AddOData”的定义,并且找不到接受“IServiceCollection”类型的第一个参数的可访问扩展方法“AddOData”(您是否缺少 using 指令或程序集引用?) JobsLedger.API C:\Users/.../JobsLedger.API\Startup.cs 35 活动
我已经添加了此服务所需的包。现在我几个月前就开始工作了。
是否有需要添加的新包?
我做错了什么,还是这是我不知道的“重大变化”?
我已经浏览了Identity 3.0的答案,并且发现很少有关于获得具有int id的单个用户.
我有一个asp.net-core mvc6项目,我在其中使用字符串id转换所有用户和角色以获得整数id.
精细.这样可行.我有一个UserAdminController,其中包括更新或编辑动作,它传递"int?" 为id.
public async Task<IActionResult> Edit(int? id)
Run Code Online (Sandbox Code Playgroud)
在我的服务中,我想让用户与整数id ..."1"相关联.
我想使用UserManger.FindByIdAsync(id)来获取具有该id的用户.
问题是,这需要一个"字符串"id而不是"int"id.
使用UserManger(如果可以的话)如何返回一个整数而不是字符串id的用户?必须有一种优雅的方式来返回用户?
我想用npm 安装这个有角度的2日历.试图使用npm安装它,然后下载并尝试安装它.在这两种情况下都失败了.
我在Windows上,我之前尝试安装angular2 CLI时遇到此错误.现在我得到了这个包的相同错误,我不知道如何纠正它.我试图取消CLI,然后清除缓存,但没有用.
有人可以查看错误,让我知道我需要采取哪些步骤来纠正这个问题.
cmd上显示的错误如下:
C:\Users\simon\SPA\ANGULAR2 CALENDAR EXAMPLE>npm install
> node-zopfli@1.4.0 install C:\Users\simon\node_modules\node-zopfli
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download: https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@1.4.0 and node@6.6.0 (node-v48 ABI) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
MSB8036: The Windows SDK version 8.1 was not found. Install the required …
Run Code Online (Sandbox Code Playgroud) 我正在迁移到 ASP.NET CORE 5.0 并设置了中间件,但是在设置我项目的这一部分时,我遇到httpContext.Session.GetString
了一个错误。这可以使用,但似乎他们已经删除了 .GetString 和 .SetString。
这是我的中间件代码。
public class ConfigureSessionMiddleware
{
private readonly RequestDelegate _next;
public ConfigureSessionMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext httpContext, IUserSession userSession, ISessionServices sessionServices)
{
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}
if (userSession == null)
{
throw new ArgumentNullException(nameof(userSession));
}
if (sessionServices == null)
{
throw new ArgumentNullException(nameof(sessionServices));
}
if (httpContext.User.Identities.Any(id => id.IsAuthenticated))
{
if (httpContext.Session.GetString("connectionString") == null) // Session needs to be set..
{ …
Run Code Online (Sandbox Code Playgroud) 我有一个操作,该操作创建访存以将客户端重新发布回API。
我在“标头”中发送了一个JWT,这本身不是问题,因为它也可以在GET中使用,而GET可以正常工作……但在POST中却没有。这是我的动作:
export const createNewClient = (payload) =>
(dispatch, getState) => {
dispatch({ type: REQUEST_CREATE_NEW_CLIENT, payload })
const jwt = getJwt()
if (!jwt) {
throw new Error('No JWT present')
}
const token = jwt.access_token
const headers = new Headers({
'Authorization': `bearer ${token}`
})
debugger
const task = fetch('/api/client/create', {
method: 'POST',
body: JSON.stringify(payload),
headers,
})
.then(handleErrors)
.then(response => response.json())
.then(data => {
dispatch({ type: RECEIVE_CREATE_NEW_CLIENT, payload: data })
dispatch({
type: SAVE_MESSAGE, payload: {
message: "Successfully saved client",
type: 'success'
} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试访问我的 dotnet core 3.1 解决方案中的 jwt 控制器。
这是我的 jwt 控制器:
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class JwtController : ControllerBase
{
#region Variables
private readonly IUserAuthorisationServices _tokenService;
private readonly IOptions<JwtTokenOptions> jwtOptions;
private readonly ILogger logger;
private readonly JsonSerializerSettings _serializerSettings;
#endregion
public JwtController(IUserAuthorisationServices tokenService,
IOptions<JwtTokenOptions> jwtOptions,
ILoggerFactory loggerFactory)
{
if (loggerFactory is null) throw new ArgumentNullException(nameof(loggerFactory));
_tokenService = tokenService ?? throw new ArgumentNullException(nameof(tokenService));
jwtOptions = jwtOptions ?? throw new ArgumentNullException(nameof(jwtOptions));
logger = loggerFactory.CreateLogger<JwtController>();
_serializerSettings = new JsonSerializerSettings {
Formatting = Formatting.Indented
};
//loggingRepository …
Run Code Online (Sandbox Code Playgroud) c# ×5
.net-core ×3
reactjs ×3
asp.net-core ×2
javascript ×2
react-redux ×2
angular ×1
fetch ×1
node.js ×1
npm ×1
odata ×1
redux ×1
redux-form ×1