我需要获得提出请求的用户ID.在以前的Identity版本中,我可以这样做:
User.Identity.GetUserId();
Run Code Online (Sandbox Code Playgroud)
但它似乎不再可用了.
还有类似的东西:
User.GetUserId();
Run Code Online (Sandbox Code Playgroud)
但它始终返回null,即使正确设置了User.Identity.IsAuthenticated并且正确设置了User.Identity.Name.
我应该用它做什么?
编辑:我的authenticaton逻辑基于[默认的Visual Studio 2015模板],到目前为止我的身份没有太大变化,所以如果你想检查它是如何完成的,你可以在我粘贴的github链接上看到它.
我需要一些方法来通过其 ID 查找视图/对象。我听说过 FindViewById 函数,但它没有出现在我的 ContentPage 类中。我在哪里可以找到它?
上下文:我有一个带有按钮的 ListView。我不知道有多少个按钮。当用户单击这些按钮之一时,我会获取其 ID 并全局存储。我想要完成的是找到这个特定的按钮,它的 id 存储在变量中。
<StackLayout x:Name="chooseObjectButtons">
<ListView x:Name="SlotsList" ItemsSource="{Binding .}" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<Button Text="{Binding Text}" BackgroundColor="Gray" Clicked="SlotChosen" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
Run Code Online (Sandbox Code Playgroud) 我正在构建aspnet核心应用程序。我想将我的MVC控制器之一保留在类库中(因此不在主项目之内)。
为了做到这一点,我在类库项目“ DataSync”中创建了新的类扩展Controller。然后,我在Startup.cs主项目文件中引用了它:
services.AddMvc().AddApplicationPart(Assembly.Load(new AssemblyName("DataSync")));
Run Code Online (Sandbox Code Playgroud)
这是当我尝试在浏览器中打开主项目时看到的错误:
TypeLoadException:无法从程序集“ Microsoft.AspNetCore.Mvc.Core,版本= 2.1.1.0,文化=中性,PublicKeyToken = adb9793829ddae60”中加载类型“ Microsoft.AspNetCore.Mvc.Internal.IHttpResponseStreamWriterFactory”。
我应该在哪里寻找可能的问题?这里可能出什么问题?
我创建了可用于在其上绘制一些形状的画布.如何将其内容保存到用户SD卡上的PNG文件中?
似乎这种方式不再可用.
public ApplicationDbContext()
{
this.Configuration.LazyLoadingEnabled = false;
}
Run Code Online (Sandbox Code Playgroud) 我正试图从这个网站运行一个样本.
问题是:为Windows 8制作了项目.当我在Visual Studio中打开解决方案时,它告诉我需要安装Windows 8 SDK才能继续.
我现在使用Windows 10 SDK,我将不再使用SDK 8,所以我宁愿不安装此SDK并使用新的一个intead.我可以以某种方式将此项目移植到Windows 10应用程序?
它现在看起来如何:
我想.py使用Windows bash控制台在Visual Studio代码中运行python 文件.
我试图做的:
更改默认shell settings.json:
{
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}
Run Code Online (Sandbox Code Playgroud)
将任务添加tasks.json到python以文件名作为参数的run 命令:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "python",
"isShellCommand": true,
"showOutput": "always",
"tasks": [
{
"taskName": "Run python in bash",
"suppressTaskName": true,
"args": ["${file}"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
这里有一些问题需要解决:
C驱动器,我需要替换 C:\为/mnt/c文件路径您可以与我的解决方案分享这些问题吗?
我的应用程序中有一个按钮,如果有人点击此按钮,我想这样做,菜单会显示出来.

它就像第一张图片上的这个菜单.这该怎么做?
假设我有一个Angular 2服务.createTokenfunction从服务器获取登录令牌:
//ANGULAR 2 SERVICE:
//login to application
createToken(email: string, password: string) {
let headers = new Headers({
'Content-Type': 'application/x-www-form-urlencoded'
});
let data = 'username=' + email + '&password=' + password + '&grant_type=password';
this.http.post(this.loginURL, data, { headers: headers })
.map(response => response.json())
.subscribe(
response => {
localStorage.setItem(this.storageTokenKey, response.access_token);
console.log("Token: " + response.access_token);
},
error => {
console.log(error.text());
});
}
Run Code Online (Sandbox Code Playgroud)
我需要用我的令牌做两件事:
为了做到这一点(据我所知,Observables),我的createToken函数必须返回Observable<>允许Component使用它来调用它的.subscribe方法对结果进行一些操作.
不幸的是,正如我从RxJS文档中看到的那样,.subscribe方法不会返回Observable<>
那我该怎么办才能调用.subscribe()方法两次呢?