如何在 IdentityServer3 的自定义 ViewService 中的自定义操作中获取 ClientId?
How to get ClientId in a custom action in custom ViewService in IdentityServer3?
我正在自定义 this MVC ViewService example IdentityServer3。
我正在尝试在 LogonWorkflowController 中添加一个自定义操作,其中数据将由来自登录页面的 post 请求提交。
我在 RouteConfig 中添加了一条新路由
routes.MapRoute(name: "ResetPasswordSend", url: "send/me/smth",
defaults: new { controller = "LogonWorkflow", action = "Send" });
并且我在 LogonWorkflowController 中添加了一个新操作
[HttpPost]
public ActionResult Send(MyCustomModell model)
{
<get ClientId?>
....
}
是否可以找到 ClientId 参数,以便能够根据此 ClientId 创建自定义答案?
谢谢。
这里是我问题的答案(参考代码MVC ViewService example):
当调用 LogonWorkflowController 的登录操作时,我们可以从消息变量中获取客户端 ID 并将其传递给 ViewBag。
ViewBag.ClientId = message.ClientId;
然后使用登录视图中的隐藏字段或使用 javascript post 我们可以将此 clientId 发送到所需的 post 操作。因此,客户端 ID 在模型的 post 操作中变得可用。
我不需要再实现它了,但我认为这是我可以做到的方式。请注意,此请求可能是伪造的,因此任何重要的事情都不应依赖于收到的 clientID。
我正在自定义 this MVC ViewService example IdentityServer3。 我正在尝试在 LogonWorkflowController 中添加一个自定义操作,其中数据将由来自登录页面的 post 请求提交。
我在 RouteConfig 中添加了一条新路由
routes.MapRoute(name: "ResetPasswordSend", url: "send/me/smth",
defaults: new { controller = "LogonWorkflow", action = "Send" });
并且我在 LogonWorkflowController 中添加了一个新操作
[HttpPost]
public ActionResult Send(MyCustomModell model)
{
<get ClientId?>
....
}
是否可以找到 ClientId 参数,以便能够根据此 ClientId 创建自定义答案?
谢谢。
这里是我问题的答案(参考代码MVC ViewService example): 当调用 LogonWorkflowController 的登录操作时,我们可以从消息变量中获取客户端 ID 并将其传递给 ViewBag。
ViewBag.ClientId = message.ClientId;
然后使用登录视图中的隐藏字段或使用 javascript post 我们可以将此 clientId 发送到所需的 post 操作。因此,客户端 ID 在模型的 post 操作中变得可用。
我不需要再实现它了,但我认为这是我可以做到的方式。请注意,此请求可能是伪造的,因此任何重要的事情都不应依赖于收到的 clientID。