This project is read-only.

Getting 404 Errors when running with Visual Studio 2012

Sep 12, 2012 at 4:19 PM

I tried following through the youtube video "Restful Objects for .NET - Creating a simple application from scratch".

These 2 urls work for me  and display correct information 



But http://localhost:57441/services/Model.CommentRepository shows a 404 error.


I am using VS2012 with an MVC4 empty web application.

The comment and comment repository classes I used are identical to the video. Here is the other class changed :

namespace RestfulApi.App_Start {
	public class RunWeb : RunRest {
		protected override NakedObjectsContext Context {
			get { return HttpContextContext.CreateInstance(); }

		protected override IServicesInstaller MenuServices {
			get { return new ServicesInstaller(new object[] {new CommentRepository()}); }

		protected override IServicesInstaller ContributedActions {
			get { return new ServicesInstaller(); }

		protected override IServicesInstaller SystemServices {
			get { return new ServicesInstaller(); }

        //protected override IObjectPersistorInstaller Persistor {
        //    get { return new EntityPersistorInstaller(); }

		//For 'Code First' development replace Persistor property with:
		protected override IObjectPersistorInstaller Persistor {
		    get {
		        return new EntityPersistorInstaller {
		            CodeFirst = true,
		            CodeFirstConfig = new[] {
		            new EntityPersistorInstaller.EntityCodeFirstConfig {AssemblyName = "Model", DataSource = @"(localdb)\v11.0", DatabaseName = "comments"}}

		public static void Run() {
			new RunWeb().Start();

The calls that fail do not seem to route into any of the controllers as I put a break point on all of them.


Sep 12, 2012 at 5:47 PM

First, please confirm the package version of Restful Objects for .NET you are using  -  I assume it's the latest, but always worth checking.

Secondly, I assume that the URL that is failing is the one provided as a link from the Services resources, yes?

You say 'not seem to route into any of the controllers'.  There should be only one controller  -  the RestfulObjectsController.  And it should be hitting that.  Do you have any other controllers there  -  or did you just mean 'not hitting any of the methods on the RestfulObjectsController?

If so, that's very puzzling.  I assume that for the working URLs you are hitting the correct controller methods OK ?


Sep 12, 2012 at 6:10 PM
Edited Sep 12, 2012 at 6:12 PM

packages are as follows :

  <package id="NakedObjects.Framework" version="4.1.1" targetFramework="net45" />
  <package id="NakedObjects.Ide" version="4.1.0" targetFramework="net45" />
  <package id="NakedObjects.ProgrammingModel" version="4.1.0" targetFramework="net45" />
  <package id="NakedObjects.Surface" version="0.10.0" targetFramework="net45" />
  <package id="NakedObjects.Surface.Nof4" version="0.15.0" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="4.5.9" targetFramework="net45" />
  <package id="RestfulObjects.Mvc" version="0.27.0" targetFramework="net45" />
  <package id="RestfulObjects.Server" version="0.22.0" targetFramework="net45" />

As far as the URL, I am starting debug, once home page displays clicking on services link, then clicking on the comment link that fails. Meant to say that i put break points on all the get methods in the controller. 

For for first two links mentioned it is calling correct methods. One other side note - when installing the nakedobjects via nuget,

it did not install the code snippets into VS2012 but instead I found them under Vs2010 and moved them across manually.

Sep 12, 2012 at 6:58 PM

I am now wondering if there might be an issue with installing into VS2012.  We are currently using VS2010 still (with MVC4 installed).  I will try it out myself on VS2012 tomorrow and see if there is an issue  -  the symptoms suggest that the routing isn't set up properly.

Sep 12, 2012 at 7:19 PM
Edited Sep 12, 2012 at 8:42 PM

I was wondering the same thing - I have vs2010 as well so will try it there also.

Update : it is working with identical code in vs2010.

Sep 13, 2012 at 9:16 AM

Thanks for checking that  -  glad you have it working on VS2010.  I've raised a ticket for the VS2012 install, which we'll look at with priority.  I'll also raise a ticket about the Snippets  (on the Naked Objects project  -  as that it where they are hosted).

Sep 14, 2012 at 10:34 AM

Just to keep you up to date ...

First, I have reproduced your error. As you say, the error is being thrown before hitting any controller methods, or even the methods in the RestDependencyResolver, which come first.

Strangely, the cause seems to be the dot in the last part of the URL.   If you create the CommentRepository with no namespace, then this URL works fine:


Clearly this is not an acceptable solution!  I just list it to illustrate the issue.

Given that all the NuGet packages (e.g. Microsoft ASP.NET Web API and its dependencies) are the same versions between VS2010 and VS2012, then this must be caused by some deeper change that Microsoft has made in VS2012.  We'll continue to investigate ...

Sep 14, 2012 at 11:04 AM
Edited Sep 14, 2012 at 11:36 AM

With the help of this post ( ) I confirmed that you can fix the issue by adding this line into your Web.config:

    <modules runAllManagedModulesForAllRequests="true" />

I tried this out and the example worked again with dots in the (last part of) the URL.

The poster refers us to this lengthy posting by Scott Hanselman : 

[Later edit]

However, I have just notice that RAMMFAR is set to true in the standard VS2010 template  -  so it turns out that that is what Microsoft has changed in VS2012.  So, in the short term we'll modify our installer to set it true anyway;  in the longer term we'll investigate alternatives.

Sep 14, 2012 at 3:00 PM
Edited Sep 14, 2012 at 3:04 PM

Yes, that fixed it for me as well.

I am having a different problem now when following along with the video.

After pasting in http://localhost:57441/services/Model.CommentRepository/actions/CreateNewComment/invoke and getting the request back,

the persist url that is returned is : http://localhost:57441/objects

When I try to post against the ../objects url I get another 404 with following exception :

[HttpException]: The controller for path &#39;/objects&#39; was not found or does not implement IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
   at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
   at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I am getting same problem with both 2010 and 2012

Sep 14, 2012 at 3:49 PM

Just to confirm that I have reproduced the issue and am looking into it.  I notice that the representation for the persist link does not seem to be consistent with the RO spec  (section B-9)  -  so I am wondering if something has gotten out of synch.

Sep 14, 2012 at 4:04 PM

If I change the link to http://localhost:57441/objects/Model.Comment consistent with the spec than it does work. 

Sep 14, 2012 at 4:12 PM

OK  -  we have an issue that needs correcting  -  I'll raise a ticket.  Just for clarity, can you confirm the exact body that you posted back to the link?

Sep 14, 2012 at 4:50 PM


request body :

                    "members": {
                        "Author": {
                            "value": "TH"
                        "Id": {
                            "value": 0
                        "Text": {
                            "value": "TT"
                    "domainType": "Model.Comment",
                    "links": [
                            "rel": "describedby",
                            "method": "GET",
                            "type": "application/json; profile=\"urn:org.restfulobjects:repr-types/domain-type\"; charset=utf-8",
                            "href": "http://localhost:57441/domain-types/Model.Comment"