当前位置: 动力学知识库 > 问答 > 编程问答 >

How to do verify domain in RESTFul with ASP.NET MVC 3?

问题描述:

Currently, I building my website personal (using ASP.NET MVC 3).

I want to provide some services to public by using API, finished building everything, but RESTFul does not contain on Authorization, I read this article:

http://blogs.msdn.com/b/rjacobs/archive/2010/06/14/how-to-do-api-key-verification-for-rest-services-in-net-4.aspx

But I could not use the method with ASP.NET MVC 3!!

I want the following:

1- Send Api-Keys for those who want to use my service

2- verify Domain (owner api-key == OR != owner domain) !!!! Is this possible?

网友答案:

You could make it a requirement that they always send their key in the requests. Then you could subclass the AuthorizeAttribute to check if the key in the request matches something in your datastore. This attribute can then be decorated on your controllers.

You can get the domain making the request using Request.UrlReferrer

分享给朋友:
您可能感兴趣的文章:
随机阅读: