我正在尝试在 ASP.NET MVC 5 (.Net Framework) 应用程序中实现 OpenId Connect 中间件。
在我的中,AccountController.cs我发送了一个 OpenID Connect 签入请求。我实现了另一个 OpenId 连接中间件,这就是为什么我指定要挑战的中间件是“AlternateIdentityProvider”。
public void SignIn()
{
HttpContext.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = "/" },
"AlternateIdentityProvider");
}
Run Code Online (Sandbox Code Playgroud)
对中间件发出质询后,RedirectToIdentityProvider事件Startup.cs触发,我被重定向到提供程序进行登录。但是,成功登录后,我被重定向到指定的重定向 uri,并添加了作为查询参数的状态和代码参数,即http: //localhost:63242/singin-oidc/?state=State&code=AuthorizationCode(为简洁起见删除了参数),这会导致 404,因为我的应用程序中不存在这样的路由。
相反,我希望成功登录会触发AuthorizationCodeReceived我可以实现附加逻辑的事件。事实上,其他事件都不会触发。
我已经在 ASP.Net Core 2.1 中实现了一个几乎相同的解决方案,在这里我能够在触发时逐步处理不同的事件。
我当前的相关代码Startup.cs如下所示。请注意,如果初始请求包含 reponse_mode 和一些遥测参数,则 OpenId 提供程序会抛出错误,因此在初始RedirectToIdentityProvider事件期间将删除这些参数。
任何想法为什么没有在中间件中接收来自 OpenId 提供程序的回调?
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions("AlternateIdentityProvider")
{
ClientId = { { Client Id } },
ClientSecret = { …Run Code Online (Sandbox Code Playgroud) 这是我的第一个MVVM项目,我需要编写的代码来操作视图中的控件似乎过于复杂.
我发现很难完全理解MVVM并决定何时可以将代码放入代码中.
基本上我的问题是我想显示一条消息告诉用户当它绑定的ObservableCollection不包含任何项时列表视图为空.我们的想法是在视图中有一个TextBlock,并且只有在没有要显示的项目时才将其visibility属性设置为Visible(在用户创建项目之前和删除所有项目之后)
我无法使用此解决方案,因为UWP不支持BooleanToVisibilityConverter: 使用BooleanToVisibilityConverter的WPF MVVM隐藏按钮
视图:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EventMaker3000.View"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ViewModel="using:EventMaker3000.ViewModel"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
x:Class="EventMaker3000.View.EventPage"
mc:Ignorable="d">
<Page.BottomAppBar>
<CommandBar>
<CommandBar.Content>
<Grid/>
</CommandBar.Content>
<AppBarButton Icon="Delete" Label="Delete" IsEnabled="{Binding DeletebuttonEnableOrNot}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Core:NavigateToPageAction/>
<Core:InvokeCommandAction Command="{Binding DeleteEventCommand}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</AppBarButton>
<AppBarButton Icon="Add" Label="Add">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Core:NavigateToPageAction TargetPage="EventMaker3000.View.CreateEventPage"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</AppBarButton>
</CommandBar>
</Page.BottomAppBar>
<Page.DataContext>
<ViewModel:EventViewModel/>
</Page.DataContext>
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!--Header-->
<TextBlock
Text="Events"
Foreground="Black"
Margin="0,20,0,0"
Style="{ThemeResource HeaderTextBlockStyle}"
HorizontalAlignment="center"
VerticalAlignment="Center"/>
<ListView
ItemsSource="{Binding EventCatalogSingleton.Events, Mode=TwoWay}"
SelectedItem="{Binding SelectedEvent, Mode=TwoWay}"
Grid.Row="1" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自定义转换.我想从视图控制器1到2进行"覆盖垂直"转换,然后在移动到View Controller 3时再次将View Controller 2(中间的一个)向下滑动.故事板如下所示:
http://i.stack.imgur.com/bJYXI.png
我正在使用从这篇文章链接到的教程.并且还使用答案中提供的代码替换了.m代码:
Xcode自定义segue - 封面垂直对面(从上到下) - COMPLETE NEWBIE
我创建了一个UIViewController的子类,并将其命名为FromTopReplaceSegue.我的.h和.m代码如下所示:
.H
#import <UIKit/UIKit.h>
@interface FromTopReplaceSegue : UIViewController
@property(nonatomic, readonly) id sourceViewController;
@property(nonatomic, readonly) id destinationViewController;
@end
Run Code Online (Sandbox Code Playgroud)
.M
#import "FromTopReplaceSegue.h"
@interface FromTopReplaceSegue ()
@end
@implementation FromTopReplaceSegue
-(void)perform{
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.75
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromTop
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; …Run Code Online (Sandbox Code Playgroud)