简体   繁体   English

Mvc4在会话未登录时设置用户数据(用于开发和测试)

[英]Mvc4 set user data in session witout login (for development and testing)

I am working on a MVC4 sub site that will only be accessible after login, the problem is that the authentication will be done on my main site (done in MVC3). 我正在MVC4子站点上工作,该子站点只能在登录后访问,问题是身份验证将在我的主站点上完成(在MVC3中完成)。

the main site stores the user data in : 主站点将用户数据存储在:

Session["UsrData"]

to carry on with development of the sub site I want to be able to simulate a login and store user data provided by me programmatically of in a config file that will refer to a test user in the database. 进行子站点的开发,我希望能够模拟登录并将我提供的用户数据以编程方式存储在配置文件中,该文件将在数据库中引用测试用户。

how can I insert the test user data into the session? 如何将测试用户数据插入会话中?

由于您的主站点为测试目的而处理每个用户的登录,因此在子站点(即Session [“ Myvar”])中手动设置会话数据,并用#if DEBUG #endif包围硬连线的会话语句

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM