.NET Framework Developer Center >
.NET Development Forums
>
ASMX Web Services and XML Serialization
>
REST Webservice with Visual Studio 2005
REST Webservice with Visual Studio 2005
- Hello
I'm trying to write a REST Webservice with VS2005 and .NET 2.0 in C#.
I was happy to find an example on http://www.codeproject.com/KB/architecture/RESTWebServicesPart2.aspx, because I'm not experienced in ASP.NET, but this example was developed with VS2008.
I tried to import the project to VS2005, but it did not work.
I started a new project in VS2005
New>>Website>>ASP.NET Web Site
It created a folder App_Data, a file Default.aspx and another file called Default.aspx.cs, which i deleted and then replaced
with the folders RESTHandlers and RESTService and the file Web.config.
The Web.config file looks like this:
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true"> </compilation> <httpHandlers> <clear/> <add verb="PUT" path="*" validate="false" type="RESTHandlers.PutHandler, RESTHandlers"/> <add verb="POST" path="*" validate="false" type="RESTHandlers.PostHandler, RESTHandlers"/> <add verb="GET" path="*" validate="false" type="RESTHandlers.GetHandler, RESTHandlers"/> <add verb="DELETE" path="*" validate="false" type="RESTHandlers.DeleteHandler, RESTHandlers"/> </httpHandlers> </system.web> <system.codedom> </system.codedom> </configuration>
In the RestHandlers folder are the handlers as you can see in the Web.config.
Then i compiled the project and it works, but when i start the service and call it with http://127.0.0.1:18103/RESTService/contact/4 it doesn't seem to work.
The link is from the project above. The questions are: Where can i see the url in iis with which i can call my service. Do i have to copy the bin directory to another place, although it is okay for me to run the service from VS?
Kind regards,
ClaudeMichelle
Answers
- Hello
I solved the problem with a ashx file(file>new>file...>generic handler).
For example:
<%@ WebHandler Language="C#" Class="GetHandler" %> using System; using System.Web; public class GetHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } }- Marked As Answer byClaudeMichelle Sunday, November 08, 2009 2:10 PM
All Replies
- Hello
I solved the problem with a ashx file(file>new>file...>generic handler).
For example:
<%@ WebHandler Language="C#" Class="GetHandler" %> using System; using System.Web; public class GetHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } }- Marked As Answer byClaudeMichelle Sunday, November 08, 2009 2:10 PM


