创建REST API为现有的基于MVC的网站 [英] Creating REST API for existing MVC based website

查看:152
本文介绍了创建REST API为现有的基于MVC的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用ASP.NET MVC3网站开发的。结果
我现在要公开给别人一个REST API使用,这将暴露出同样的功能的网站。

I have a website developed using ASP.NET MVC3.
I now want to expose a REST API for others to use which will expose the same features as the website.

在网站上,一旦用户登录并验证凭据针对DB,会话管理登录的用户的状态。结果
我怎么会做的REST API,在许多公开的方法要求用户先登录等价(或至少具有有效的用户名和密码)?

In the website, once a user has logged in and credentials validated against a DB, the session manages the logged-in state of the user.
How would I do the equivalent with the REST API, where many of the methods exposed require the user to be logged in (or at least have valid username and password)?

在除此之外,将用于该网站的最佳方法是使用REST API还(presuming该API涵盖由网站所要求的所有的功能)?

In addition to this, would the best approach for the website be to use the REST API also (presuming the API covers all the functionality required by the site)?

如何以及在ASP.NET MVC3适合此 - 当然考虑到,该网站已经存在使用这个框架

How well is ASP.NET MVC3 suited for this - of course taking into account that the site already exists using this framework?

推荐答案

我写了一篇博客文章中对如何[一个ASP.NET MVC 3应用程序中构建RESTful API架构] 年前<击>而最后不得不让现场去。 :( <罢>如果你想利用打造的REST API到你的MVC应用程序这可能是一个良好的开端。

I wrote up a blog post on how to [Build a RESTful API architecture within an ASP.NET MVC 3 application] years ago and ended up having to let the site go. :( It might be a good start if you want to take on building the REST API into your MVC application.

请参阅使用的WebAPI一个很好的解决方案回答通过@tugberk。

See answer by @tugberk on using WebAPI for a good solution.

这篇关于创建REST API为现有的基于MVC的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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