我正在开发一个自托管的ASP.NET web api-application.一切正常,但现在我正在努力HttpContext:
我需要从客户端保存会话信息.但HttpContext.Current总是空的.所以很明显我HttpSelfHostServer不使用静态HttpContext-Class.
我不明白的是:为什么......?而且我无法想办法既不告诉也HtttpSelfHostServer不能HttpSelfHostConfiguration合作HttpContext.
这是我正在做的事情:
创建一个 HttpSelfHostConfiguration
Service-Resolvers&RoutesUserNamePassword-Validator使用config创建新的HttpSelfHostServer实例
server.OpenAsync().Wait()任何帮助我如何告诉我的服务器工作HttpContext.Current非常感谢!干杯!
这就是我现在所拥有的
Container.RegisterType<IUserManager, UserManagerMock>();
Container.RegisterType<IUser, UserMock>(
new InjectionFactory(
(c) => c.Resolve<IUserManager>().GetUser("John")));
Run Code Online (Sandbox Code Playgroud)
得到它
Container.Resolve<IProfile>();
Run Code Online (Sandbox Code Playgroud)
我想将一个名称作为参数传递给Factory,以便我能够用名称解析用户对象; 像这样的东西:
Container.Resolve<IProfile>("Jonh");
Run Code Online (Sandbox Code Playgroud)
如何更改此案例的类型注册?