更新时间:2023-02-25 16:46:20
多摆弄周围,显然勾ServiceStack认证方式后可通过拨打AuthService:
After much fiddling around, apparently the way to hook ServiceStack authentication is to call the AuthService via:
try {
authResponse = AuthService.Authenticate(new Auth{ UserName = model.UserName, Continue = returnUrl, Password = model.Password });
} catch (Exception ex) {
// Cut for brevity...
}
和不可以 authResponse = this.CreateRestClient()发表< AuthResponse>(/认证/资格证书,模型);!
其中, AuthService
在基控制器的定义是:
Where AuthService
is defined in the base controller as:
public AuthService AuthService
{
get
{
var authService = ServiceStack.WebHost.Endpoints.AppHostBase.Instance.Container.Resolve<AuthService>();
authService.RequestContext = new HttpRequestContext(
System.Web.HttpContext.Current.Request.ToRequest(),
System.Web.HttpContext.Current.Response.ToResponse(),
null);
return authService;
}
}
其他的一切(包括会话)现在可以正常工作。
Everything else (incl. session) works correctly now.