MVC3 中的会话级身份验证
我正在将音频文件从 Windows Phone 客户端分块上传到 MVC3 应用程序,
我编写了一个带有 HttpPost
属性装饰 Action 的控制器,用于处理传入的块。
该操作的签名是:
[HttpPost]
public JsonResult RecieveChunk(string id, [ModelBinder(typeof(AudioChunkModelBinder))] byte[] audio)
id
在本例中,是文件上传会话的 ID,大概会在实际块 POST
涌入之前由客户端和服务器协商在
Windows Phone 端,HttpWebRequest
的实例正在执行上传工作,当前没有进行身份验证。
在服务器上,我需要能够知道每个帖子来自谁。
有没有办法让我从 MVC3 站点获取某种访问令牌,以便能够 POST 到站点的特定 Uri,但不需要发送用户 ID 和密码作为 Uri 的一部分?
在我的场景中,什么是适合我的身份验证方法?
I am uploading audio file in chunks from a Windows Phone client to an MVC3 application
I have written a Controller with an HttpPost
attribute decorated Action, that is processing an incoming chunks.
The action's signature is:
[HttpPost]
public JsonResult RecieveChunk(string id, [ModelBinder(typeof(AudioChunkModelBinder))] byte[] audio)
id
in this case, is an id of a file upload session, that presumably will get negotioated by client and server before actual chunk POST
s will come pouring in.
On the Windows Phone side, an instance of HttpWebRequest
is doing the upload work with no authentication currently in place.
On the server, I need to be able to know, from whom each post is coming from.
Is there a way for me to obtain a some kind of an access token from an MVC3 site to be able to POST to a site's specific Uri, but without a need to send a user ID and a Password as a part of a Uri?
What can be an authentication approach for me in my scenario?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用内置的 ASP.NET / MVC 身份验证机制进行身份验证,则可以检查服务器上的
User.Identity
(请参阅 http://msdn.microsoft.com/en-us/library/ewfkf772.aspx) 获取有关当前用户。当然,这假设您正在使用 凭据
HttpWebRequest
的 属性用于在请求之间保留身份验证数据。If you're authenticating with the built-in ASP.NET / MVC authentication mechanisms, you can check the
User.Identity
on the server (see http://msdn.microsoft.com/en-us/library/ewfkf772.aspx) to get information about the current user.This assumes, of course, that you're using the Credentials property of
HttpWebRequest
to persist authentication data between requests.