在ASP.NET MVC3提供的参数,而不是默认行为,使用会话ID [英] Use Session ID from supplied parameter instead of default behavior in ASP.NET MVC3

查看:161
本文介绍了在ASP.NET MVC3提供的参数,而不是默认行为,使用会话ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC3控制器JSON的输入/输出编写一个简单的证明了概念Web服务。我想允许基于一个数据库表中的登录和返回一个API密钥和一个会话ID 即可。随着后续请求其他API我需要通过这两个API密钥和会话ID。

I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON input/output. I want to allow a login based on a DB table and to return an API key and a session ID. With subsequent requests to other APIs I require passing both API key and a session ID.

如何设置我的MVC3项目,以便正在使用的cookie也不Cookie会话都不是。我想用来代替从JSON请求会话ID,仍然有一个 Controller.Session 的便利。这可能吗?我不想用我自己的会话处理推倒重来。

How can I set up my MVC3 project so that neither cookie nor cookieless session is being used. I want the session ID from JSON request to be used instead and still have the convenience of a Controller.Session. Is this possible? I don't want to reinvent the wheel with my own session handling.

推荐答案

您可以使用的 ISessionIDManager 接口来创建自定义逻辑用于存储和检索的SessionID。

YOu can use the ISessionIDManager interface to create custom logic for storing and retrieving the sessionID.

您在你的web.config设置应用程序使用您的自定义会话ID管理而不是默认的,然后你要做的就是找​​出你想要的保存到该请求并从请求检索。

You set in your web.config that the app uses your custom session id manager instead of the default one and then all you have to do is figure out how you want it to save to the request and retrieve from the request.

这篇关于在ASP.NET MVC3提供的参数,而不是默认行为,使用会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆