Response.Write()果园

时间:2017-05-17 05:40:35

标签: c# orchardcms

我创建了EventHandler,当用户使用Orchard登录时调用我的服务。然后我需要发送带令牌的js脚本。我试图使用httpContext.Response.Write(),但它在我的EventHandler中不起作用(我是 在Orchard和web api初学者,所以我需要一些帮助。

public class LoginUserEventHandler : IUserEventHandler {
    private readonly IAuthService _authService;
    private readonly IHttpContextAccessor _httpContextAccessor;

    public LoginUserEventHandler(IAuthService authService, IHttpContextAccessor httpContextAccessor) {
        _authService = authService;
        _httpContextAccessor = httpContextAccessor;
    }

    public void Creating(UserContext context) {
        throw new NotImplementedException();
    }

    public void Created(UserContext context) {
        throw new NotImplementedException();
    }

    public void LoggingIn(string userNameOrEmail, string password) {
        throw new NotImplementedException();
    }

    public void LoggedIn(IUser user) {
       var token = _authService.GenerateLocalAccessTokenResponse(user.UserName);
        var httpContext = _httpContextAccessor.Current();
        httpContext.Response.Write(token);
    }

更新: 我需要在JQuery字符串中发送令牌,类似于:

var tokenKey = "tokenInfo";
sessionStorage.setItem(tokenKey, data.access_token);

0 个答案:

没有答案