下面是我的SignalR集线器代码,在其中创建cookie时会给出异常。
using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using Test.Models;
namespace Test.Classes
{
public class HomeHub : Hub
{
public void Login(LoginModel model)
{
HomeManager manager = new HomeManager();
ActionOutput<UserDetails> Result = manager.LoginUser(model);
if (Result.Status == ActionStatus.Successfull)
{
HttpCookie auth = Common.CreateCustomAuthorisationCookie(model.Username, false, new JavaScriptSerializer().Serialize(Result.Object));
Context.Request.GetHttpContext().Response.Cookies.Add(auth);
}
Clients.Caller.loginCallback(new ActionOutput { Message = Result.Message, Status = Result.Status });
}
}
}