Вы находитесь на странице: 1из 23

Test

Doug Seven
Software Development Engineer Lead
doug.seven@microsoft.com
http://blogs.msdn.com/dseven

Enabling RESTful Web Applications in ASP.NET


Session Agenda

 REST: An Overview
 ASP.NET: Virtual File System
 Pulling It All Together
 Summary
REST: An Overview

 REpresentational State Transfer


 Application state and functionality are
divided into resources.
 Every resource is uniquely addressable.

http://en.wikipedia.org/wiki/REST
REST: An Overview (cont)

 All resources share a uniform interface


for the transfer of state between client
and resource, consisting of…
 A constrained set of well-defined
operations.
 A constrained set of content types,
optionally supporting code-on-demand.

http://en.wikipedia.org/wiki/REST
REST: An Overview (cont)

 A protocol that is:


 Client/Server
 Stateless
 Cacheable
 Layered

http://en.wikipedia.org/wiki/REST
REST vs. SOAP

 SOAP RPC: Verb based.


 GetUser(string userId)
 AddUser(User u)

 REST: Noun based.


 http://mysite/users/dseven
 http://mysite/users/newUserForm

 REST does NOT require a separate page for


each data item, just a separate address.
The VirtualPathProvider

 Provides a set of methods that enable a Web


application to retrieve resources from a
virtual file system.
 System.Web.Hosting Namespace.
 Must Override:
 FileExists
 GetFile
The VirtualPathProvider – Can

 You can store any file that is processed on


request in a virtual file system.
 ASP.NET pages, etc.
 Standard Web pages.
 Any custom extension mapped to a BuildProvider.
 Any named theme in the App_Theme folder.
The VirtualPathProvider – Cannot

 You cannot store…


 ASP.NET application folders
 Files/Directories that generate application-level
assemblies.
 Global.asax, Web.config
 Sitemap files used by the XmlSiteMapProvider
 /bin
 /App_Code, /App_GlobalResources , etc.
 The application data folder (/App_Data).
The VirtualFile

 Represents a file object in a virtual file or


resource space.
 Implement a descendant of VirtualFile for
each object type in your system.
 System.Web.Hosting Namespace.
 Must Override:
 Open
RegisterVirtualPathProvider

 Registers a new VirtualPathProvider instance with


the ASP.NET compilation system.
 Runs from a static class in /App_Code.
public static class AppStart{
public static void AppInitialize(){
MyPathProvider provider =
new MyPathProvider();
HostingEnvironment.
RegisterVirtualPathProvider(provider);
}
}

 Can run from Application_Start event.


Doug Seven
Software Development Engineer Lead
doug.seven@microsoft.com
http://blogs.msdn.com/dseven

Demo available at http://blogs.msdn.com/dseven

Вам также может понравиться