我正在google以获取ASP.NET Identity 3.0中的控制器中的应用程序用户,但我只找到5及更低的结果.
我试图获得ApplicationUser属性,但我无法得到它ApplicationUser.我想这很容易,因为我是唯一有这个问题的人.
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Data.Entity;
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNet.Identity;
using System.Security.Claims;
namespace ApplicationUserFMLTest.Controllers
{
public class CustomClassController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
private ApplicationDbContext _context;
public CandidatesController(ApplicationDbContext context, UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager)
{
_context = context;
_userManager = userManager;
_signInManager = signInManager;
}
// GET: CustomClass
public async Task<IActionResult> Index()
{
ApplicationUser currentUser = _userManager.FindByIdAsync(User.Identity.GetUserId()).Result;
if (currentUser.PropBool) …Run Code Online (Sandbox Code Playgroud) 我在PowerShell脚本中不断收到以下异常:
方法调用失败,因为[System.Xml.XmlElement]不包含名为CreateElement'的方法.
但据我所知,我正在使用System.Xml.XmlDocument?
https://msdn.microsoft.com/en-us/library/fw1ys7w6(v=vs.110).aspx
我究竟做错了什么?
$file = "file.xml"
$xmlDoc = [System.Xml.XmlDocument](Get-Content $file)
if ($xmlDoc) {
$xmlDoc.layout.nodes.SetAttribute("environment", "develop"); #this works
$newNode = $xmlDoc.layout.nodes.CreateElement("Node")
$newNode.SetAttribute("name", "Hello world")
$xmlDoc.AppendChild($newNode)
$xmlDoc.Save($systemConfigFile)
}
Run Code Online (Sandbox Code Playgroud)
XML文件在我启动此脚本之前:
<layout>
<nodes enviroment="[uknown]">
</nodes>
</layout>
Run Code Online (Sandbox Code Playgroud)
我期待结果te成为:
<layout>
<nodes enviroment="develop">
<node name="Hello world" />
</nodes>
</layout>
Run Code Online (Sandbox Code Playgroud) 我试图从翻译中获取 XmlElement 的值。
当我调试代码时,该值为空。Translations.Section.Translation我正在尝试获取in的值Translation.cs。我似乎无法找出我做错了什么以及为什么。谁能向我解释我需要做什么?
我已经走到这里了,但我不知道如何填充该值。
<?xml version="1.0" encoding="utf-8"?>
<Translations code="nl" description="Dutch" xmlns="urn:Test.Translations">
<Section name="Module">
<Translation key="SystemConfiguration">Systeem configuratie</Translation>
</Section>
<Section name="Feature">
<Translation key="Feature">Feature</Translation>
<Translation key="Name">Naam</Translation>
<Translation key="IsEnabled">Actief</Translation>
</Section>
</Translations>
Run Code Online (Sandbox Code Playgroud)
[Serializable()]
[XmlRoot(Namespace = "urn:Test.Translations", ElementName = "Translations", DataType = "string", IsNullable = true)]
public class Translations
{
[XmlAttribute("code")]
public string Code { get; set; }
[XmlAttribute("description")]
public string Description { get; set; }
[XmlElement("Section")]
public List<Section> Sections { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
public class Section …Run Code Online (Sandbox Code Playgroud) 我有一个联系表格 7,客户坚持根据复选框选择转到不同的邮箱。
我可以通过以下方式做到这一点:
[checkbox* your-recipient class:checks label_first use_label_element exclusive "Sales | email@address1.co.uk" "Rent| email@address2.co.uk"]
Run Code Online (Sandbox Code Playgroud)
这很有效,但在邮件表单上,他们希望主题是键而不是值?
Subject: Contact form enquiry - [your-recipient]
Run Code Online (Sandbox Code Playgroud)
这将返回:
Subject: Contact form enquiry - email@address1.co.uk
Subject: Contact form enquiry - email@address2.co.uk
Run Code Online (Sandbox Code Playgroud)
有没有办法让主题阅读:
Subject: Contact form enquiry - Sales
Subject: Contact form enquiry - Rent
Run Code Online (Sandbox Code Playgroud)
非常感谢
对于学校我需要用JavaScript编写一个游戏,但问题是我不明白这部分代码意味着什么:
if (typeof game_loop != "undefined") clearInterval(game_loop);
game_loop = setInterval(paint, 60);
Run Code Online (Sandbox Code Playgroud) 如果我做:
var organisationList = _context.OrganisationCategory.ToList();
Run Code Online (Sandbox Code Playgroud)
它只返回没有组织和类别的列表.它没有回馈组织和类别模型,而是我得到一个列表:
1, null, null
2, null, null
3, null, null
Run Code Online (Sandbox Code Playgroud)
我想我弄错了?在数据库中是组织的ID和正确设置的类别.
OrganisationCategory模型:
public class OrganisationCategory
{
public int ID { get; set; }
public Organisation Organisation { get; set; }
public Category Category { get; set; }
public OrganisationCategory() { }
public OrganisationCategory(Organisation Organisation, Category Category)
{
this.Organisation = Organisation;
this.Category = Category;
}
}
Run Code Online (Sandbox Code Playgroud)
ApplicationDbContextMOdelSnapshot.cs:
modelBuilder.Entity("Implicietmeten.Models.Organisations.Categories.OrganisationCategory", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int?>("CategoryID");
b.Property<int?>("OrganisationID");
b.HasKey("ID");
});
Run Code Online (Sandbox Code Playgroud) 我得到以下字符串:
a:16:{i:0;s:1:"6";i:1;s:2:"12";i:2;s:1:"2";i:3;s:2:"11";i:4;s:1:"7";i:5;s:2:"10";i:6;s:2:"16";i:7;s:1:"5";i:8;s:1:"3";i:9;s:1:"1";i:10;s:2:"14";i:11;s:1:"8";i:12;s:2:"13";i:13;s:1:"9";i:14;s:1:"4";i:15;s:2:"15";}
Run Code Online (Sandbox Code Playgroud)
我不能用
var_dump(json_decode($json))
Run Code Online (Sandbox Code Playgroud)
因为它不会返回任何东西.我找到了两个有用的网站:http: //jsonlint.com/用于检查对象是否有效(不是什么)和http://www.unserialize.com/可以'反序列化'json字符串返回数组.
现在我想知道反序列化对json字符串的作用.所以我也可以在我的脚本中使用它.
c# ×3
php ×2
xml ×2
asp.net-core ×1
forms ×1
identity ×1
if-statement ×1
javascript ×1
json ×1
powershell ×1
undefined ×1