查看SignalR 绑定的文档以向指定用户发送消息,您UserId在消息中包含该属性 -
[FunctionName("SendMessage")]
public static Task SendMessage(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message,
[SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
return signalRMessages.AddAsync(
new SignalRMessage
{
// the message will only be sent to these user IDs
UserId = "userId1",
Target = "newMessage",
Arguments = new [] { message }
});
}
Run Code Online (Sandbox Code Playgroud)
此示例直接取自文档,但注释暗示您向多个用户 ID发送消息,即使该属性是字符串而不是数组。
您将如何指定多个用户?(例如,如果他们一起在私人聊天频道中)或者评论的措辞是否存在错误,您需要为每个用户发送一条消息?
对于其他版本的 SignalR,我会将它们放在一个组中,但函数不存在此绑定。
我有一个模型:
public class FormCreateModel
{
public FormModel formInfo { get; set; }
public FieldModel fieldInfo { get; set; }
public InstitutionModel selectedInst { get; set; }
public FormTypeModel selectedFormType { get; set; }
public CategoryModel categoryInfo { get; set; }
public List<InstitutionModel> institutions { get; set; }
public List<FormTypeModel> FormTypes { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我为这个模型创建了一个强类型视图:
@using (Html.BeginForm())
{
<p>
@Html.LabelFor(lbl =>lbl.selectedInst.Institution_Name, "Institution Name :", new { @class="lblName"})
@Html.DropDownListFor(drpdown => drpdown.selectedInst.Institution_Name, new SelectList(Model.institutions.Select(inst => inst.Institution_Name)),"-- select Institution--", new { @class …Run Code Online (Sandbox Code Playgroud) 我正在尝试使 App Insights 工作,以便我可以使用以下方法调试我的策略:
https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-troubleshoot-custom
并基于这个项目:https : //github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/tree/master/LocalAccounts
进行了适当的修改:
<TrustFrameworkPolicy
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06"
PolicySchemaVersion="0.3.0.0"
TenantId="B2CPruebaProteccion.onmicrosoft.com"
PolicyId="B2C_1A_PasswordReset"
PublicPolicyUri="http://B2CPruebaProteccion.onmicrosoft.com/B2C_1A_PasswordReset
UserJourneyRecorderEndpoint="urn:journeyrecorder:applicationinsights">
<BasePolicy>
<TenantId>B2CPruebaProteccion.onmicrosoft.com</TenantId>
<PolicyId>B2C_1A_TrustFrameworkExtensions</PolicyId>
</BasePolicy>
<RelyingParty>
<DefaultUserJourney ReferenceId="PasswordReset" />
<UserJourneyBehaviors>
<JourneyInsights TelemetryEngine="ApplicationInsights" InstrumentationKey="00000000-0000-0000-0000-000000000000" DeveloperMode="true" ClientEnabled="false" ServerEnabled="true" TelemetryVersion="1.0.0" />
</UserJourneyBehaviors>
<TechnicalProfile Id="PolicyProfile">
...
</TrustFrameworkPolicy>
Run Code Online (Sandbox Code Playgroud)
我的数据未显示在 App Insights 中。如何验证/修复此错误?
我有以下数据模型:
public class Foo
{
public Foo(int barId)
{
BarId = barId;
}
private int BarId;
public Bar Bar { get; private set; }
}
public class FooTypeConfig : IEntityTypeConfiguration<Foo>
{
public void Configure(EntityTypeBuilder<Foo> builder)
{
builder.HasOne(x => x.Bar)
.WithMany()
.HasForeignKey("BarId");
}
}
public class Bar
{
public int Id { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
效果很好,根据我的期望,我有一个Foo包含Id和的表BarId。从数据库中读取时,我的私有字段BarId和我的Bar财产也已正确实现Foo。
问题是我想找到一种方式来命名我的私有字段,并为我的数据库列选择一个不同的名称。我想命名我的财产_barId,但仍选择BarId数据库中的列名。
这可能吗?
我试图重命名我的Foo班级中的字段,并_barId在我的我的外键中指定我的(现在是非常规名称)外键 …
我按照使用 Azure Active Directory B2C 注册、登录、配置文件编辑和密码重置创建 ASP.NET Web 应用中的步骤进行操作,并使用示例代码为我们公司制作了 Azure AD B2C 原型。
关于问题可能是什么的任何建议吗?
当我尝试使用 MSAL.js 获取访问令牌时,我收到:
由于超时,令牌更新操作失败:空
我该如何调试?
为什么我在 Chrome 中看不到这个隐藏的网络流量iframe?我在 Edge 中看到了它们。
背景:我部署了一个 Azure Function App,并使用 AAD 启用了应用服务身份验证 (easyauth),并连接到 Azure AD B2C 租户。一切都很顺利并且符合预期。也就是说,我遇到了一个新场景,我想使用相同的功能应用程序来支持该场景,但无需打开身份验证。具体来说,我希望匿名调用一个特定函数(甚至可能在函数代理后面)。
问题:是否可以在同一功能应用程序中禁用特定功能的身份验证,而其他所有功能都已强制执行身份验证?
我尝试过将“请求未经身份验证时采取的操作”更改为“允许匿名请求(无操作) ”的想法,但这让我在需要身份验证的每个其他功能中以某种方式完成任务,确保请求实际上经过身份验证的东西。请注意,我不知道在这种情况下我必须做什么。
最糟糕的情况是,我将设置一个完全独立的函数应用程序,它只公开我需要匿名调用的单个函数……但是,感觉应该有一个更好的解决方案,不需要我在两个项目之间共享源代码。
我正在遵循本指南,并且正在尝试使用 MS Test 编写类似的测试。的确MS测试有一个IsType()是返回对象当铸造成功?
从这个比较中,我看到我可以使用IsInstanceOfType()但返回类型是void.
我正在尝试在 MS 测试中实现这一行:
var badRequestResult = Assert.IsType<BadRequestObjectResult>(result);
[Fact]
public async Task IndexPost_ReturnsBadRequestResult_WhenModelStateIsInvalid()
{
// Arrange
var mockRepo = new Mock<IBrainstormSessionRepository>();
mockRepo.Setup(repo => repo.ListAsync()).Returns(Task.FromResult(GetTestSessions()));
var controller = new HomeController(mockRepo.Object);
controller.ModelState.AddModelError("SessionName", "Required");
var newSession = new HomeController.NewSessionModel();
// Act
var result = await controller.Index(newSession);
// Assert
var badRequestResult = Assert.IsType<BadRequestObjectResult>(result);
Assert.IsType<SerializableError>(badRequestResult.Value);
}
Run Code Online (Sandbox Code Playgroud)
是的,我可以使用as然后使用IsInstanceOfType……只是想知道是否有单线。
var badRequestResult = result as BadRequestObjectResult;
Assert.IsInstanceOfType(badRequestResult, typeof(BadRequestObjectResult)); …Run Code Online (Sandbox Code Playgroud)