Restful web service Endpoint not found

I am trying to build a basic REST web service that simply returns the current time and whenever I try to I get the following error whenever I try to call my service http://localhost:PORT/TimeService/CurrentTime:

Endpoint not found. Please see the service help page for constructing valid requests to the service.

What am I doing wrong? Below you can find all the code I am using. Thank You


using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace WcfRestService1
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class TimeService
        [WebGet(UriTemplate = "CurrentTime")]
        public string CurrentTime()
            return DateTime.Now.ToString();


using System;
using System.ServiceModel.Activation;
using System.Web;
using System.Web.Routing;

namespace WcfRestService1
    public class Global : HttpApplication
        void Application_Start(object sender, EventArgs e)

        private static void RegisterRoutes()
            RouteTable.Routes.Add(new ServiceRoute("TimeService",
                new WebServiceHostFactory(), typeof(TimeService)));


<?xml version="1.0"?>

    <compilation debug="true" targetFramework="4.0" />

    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>



This is one of the best articles I found when I first started learning rest; I wish I was at work now I have the exact TimeService example but I just Googled and could not find the same code.

Tomorrow from work I will post a working example if you still need it.

Need Your Help

Making links with no href accessible

javascript html accessibility wai-aria wai

A third party script is being used on a site I work on that replaces a few instances of &lt;a href=""&gt; with simple &lt;a&gt;. The links still work thanks to another part of the script. But they ...

searching for a sub string in an array in php

php arrays string

I'm trying to search for the occurrence of certain words in a string and match them with a short list in an array. I'll explain my question by means of an example.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.