ASP.net MVC与RESTful ROA还是有点区别的
以blog系统为例,一个简单的blog系统模型包括:
1.发表一篇新的blog
2.显示一篇blog
3.修改一篇blog
4.删除一篇blog
ASP.net MVC会是这样的URL规划:
*. http://www.gaotianpu.com/blog/create,创建
get方法给用户展示一个html表单,供用户提交数据
post方法接受用户提交的数据,插入到db
*. http://www.gaotianpu.com/blog/123,获取展示blog id为123的blog
*. http://www.gaotianpu.com/blog/Edit/123,修改
get,展示编辑用的html表单
post,接受编辑后的数据
*. http://www.gaotianpu.com/blog/Delete/123,删除
通常都用get方法执行.
MVC会在url中显示的给出资源的操作方法,另外,MVC还要负责输出用户交互界面。
而RESTful ROA思想则会这样规划URL
http://www.gaotianpu.com/blog/123
使用Http Method来区分针对该资源的操作:
*. get,获取id=123的blog
*. put,修改id=123的blog
*. delete,删除id=123的blog
http://www.gaotianpu.com/blog/,
*. post,表示创建一新blog。
(为了保证幂等操作,即防止重复提交相同内容,post方法会附加一个guid参数,若两次提交的guid参数相同,则表示重复提交,后一次提交的覆盖前一次。)
*. get ,加载blog列表.
当然,普通的web form是不支持put,delete,head,option等这样的特殊http方法的,但可以在post基础上模拟得到.
为什么会有这样的区别呢?
RESTful Web Service,就是用来提供web服务的,和asp.net mvc不同,它可以不考虑用户交互界面。
比如说,当创建、修改一篇blog时,asp.net mvc同一url要支持2种方法:get,给用户一个可操作的界面,post接受用户提交的数据,
而rest则不用考虑给用户这样的操作界面,操作界面要由客户端完成。
二者不存在谁替换谁,谁比谁更好的问题。
简单比较了一下,个人觉得使用ASP.net MVC 来实现RESTful webservice还是有些牵强的,不知道WCF是如何处理RESTfull web serivce的 ?
最新版本:http://www.gaotianpu.com/blog/detail/248
相关文档:
xtreeView.js
---==========================================================
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById("Panel2")
function showmenuie5(e)
{
&n ......
使用ASP.NET 2.0 Profile存储用户信息[翻译] Level 200
作者: Stephen Walther
原文地址:http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnvs05/html/UserProfiles.asp
译者:Tony Qu
概要:许多ASP.NET应用程序需要跨访问的用户属性跟踪功能,在ASP.NET1.1中,我们只能人工实现这一功能。但如 ......
画面:
<asp:HiddenField ID="hfdXuHao" runat="server" />
<asp:TreeView ID="tvMenu" runat="server" CssClass="tvStyle" EnableClientScript="false"
& ......
asp.net 对xml文件的读写,添加,修改,删除操作
下面有代码调试正确
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using&nb ......