我开始与"个人用户帐户"身份验证选项创建的.NET Web API启动模板时(如描述在这里).正确生成令牌,但".issued"和".expires"属性采用非ISO日期格式.如何对其进行格式化以DateTime.UtcNow.ToString("o")符合ISO 8601标准?
{
"access_token": "xxx",
"token_type": "bearer",
"expires_in": 1199,
"userName": "foo@bar.com",
"Id": "55ab2c33-6c44-4181-a24f-2b1ce044d981",
".issued": "Thu, 13 Aug 2015 23:08:11 GMT",
".expires": "Thu, 13 Aug 2015 23:28:11 GMT"
}
Run Code Online (Sandbox Code Playgroud)
该模板使用自定义OAuthAuthorizationServerProvider并提供一个钩子来向传出令牌添加其他属性('Id'和'userName'是我的道具),但我没有看到任何方法来更改现有属性.
我注意到在覆盖中TokenEndpoint,我得到了OAuthTokenEndpointContext一个带有.issued和.expired键的属性字典.但是,尝试更改这些值无效.
非常感谢提前.
我已经看到几个对WebServiceHost2Factory的引用作为用于有效处理WCF Rest服务中的错误的类.显然,在该类中,我只需要抛出一个WebProtocolException,并且响应的主体将包含相关信息.
这堂课现在似乎已经失宠了..NET 4堆栈中是否存在替换?
我想弄清楚如果出现问题,如何在POST操作的响应体中返回错误文本.关键问题是在所有*的旁边
例:
[Description("Performs a full enroll and activation of the member into the Loyalty program")]
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/fullenroll/{clientDeviceId}",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
public MemberInfo FullEnroll(string clientDeviceId, FullEnrollmentRequest request)
{
Log.DebugFormat("FullEnroll. ClientDeviceId: {0}, Request:{1}", clientDeviceId, request);
MemberInfo ret = null;
try
{
//Do stuff
}
catch (FaultException<LoyaltyException> fex)
{
Log.ErrorFormat("[loyalty full enroll] Caught faultexception attempting to full enroll. Message: {0}, Reason: {1}, Data: {2}", …Run Code Online (Sandbox Code Playgroud) tl; dr-如何获取click()myButton组件上的处理程序以兑现按钮的禁用状态?
我有一个自定义按钮组件,用于将外观和感觉相似的按钮组成组件,包括文本和FA图标。按钮组件将获得某些输入,包括其文本和一个标志,指示其是否已禁用。禁用后,它会正确显示(即,光标变暗且不吸烟),但其click()处理程序始终会收到点击。
我想我知道为什么会这样,但是我不知道如何解决。我试过Output() click = new EventEmitter<any>()在按钮组件上声明一个,以为Angular会以某种方式正确地将其连接起来,但这没有用。
我的按钮的使用者可以这样操作:
//foo.component.html
...
<my-button
(click)="saveWidget()"
[disabled]="shouldBeDisabled"
type="{{buttonTypes.save}}">
</myButton>
...
//foo.component.ts
import { ButtonTypes } from './myButton';
export class FooComponent implements OnInit {
buttonTypes = ButtonTypes;
saveWidget() {
//do some saving
}
get shouldBeDisabled() {
return true; //Normally a real test in here
}
...
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,使用此按钮时,saveWidget()无论my-button的禁用状态如何,都将调用单击处理程序(即foo.component上)。
按钮组件看起来像这样:
export enum ButtonTypes {
add,
cancel,
save,
}
@Component({
selector: 'my-button',
template: `<button [type]="tagType"
[disabled]="disabled" …Run Code Online (Sandbox Code Playgroud)