Having trouble with routing

136 views
Skip to first unread message

Namith

unread,
Apr 22, 2013, 12:55:53 PM4/22/13
to fubumv...@googlegroups.com
Hello guys, pulled all new nugets from teamcity.

<package id="Bottles" version="1.0.0.472" targetFramework="net45" />
<package id="FubuCore" version="1.1.0.242" targetFramework="net45" />
<package id="FubuLocalization" version="0.9.5.137" targetFramework="net45" />
<package id="FubuMVC.Core" version="1.0.1.1453" targetFramework="net45" />
<package id="FubuMVC.Core.Assets" version="0.9.9.425" targetFramework="net45" />
<package id="FubuMVC.Core.UI" version="1.0.1.450" targetFramework="net45" />
<package id="FubuMVC.Core.View" version="1.0.0.432" targetFramework="net45" />
<package id="FubuMVC.Diagnostics" version="0.9.6.223" targetFramework="net45" />
<package id="FubuMVC.JQueryUI" version="0.5.0.248" targetFramework="net45" />
<package id="FubuMVC.Media" version="0.9.5.340" targetFramework="net45" />
<package id="FubuMVC.Navigation" version="0.9.0.94" targetFramework="net45" />
<package id="FubuMVC.Razor" version="1.0.0.432" targetFramework="net45" />
<package id="FubuMVC.SlickGrid" version="0.0.0.537" targetFramework="net45" />
<package id="FubuMVC.Spark" version="1.0.0.432" targetFramework="net45" />
<package id="FubuMVC.StructureMap" version="1.0.1.1453" targetFramework="net45" />
<package id="FubuMVC.TwitterBootstrap" version="0.0.0.533" targetFramework="net45" />
<package id="HtmlTags" version="1.2.0.158" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.20715.0" targetFramework="net45" />
<package id="Spark" version="1.7.5.1" targetFramework="net45" />
<package id="structuremap" version="2.6.4.69" targetFramework="net45" />


On a simple app  (copied from example app) with one endpoint

namespace Test
{
    public class HomeEndpoint
    {

        public HomeViewModel Index(HomeInputModel input)
        {
            return new HomeViewModel();
        }

        public ListViewModel List(HomeInputModel input)
        {
            return new ListViewModel();
        }
        
    }

    public class ListViewModel
    {
        public string ListMessage { get; set; }
    }

    public class HomeViewModel
    {
        public string HomeMessage { get; set; }
    }

    public class HomeInputModel
    {
    }
}


in Global.asax

namespace Test
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            FubuApplication.For<HelloWorldRegistry>()
                .StructureMap(new StructureMap.Container())
                .Bootstrap();

        }

.
.
.
.

the helloworl registry

         public class HelloWorldRegistry : FubuRegistry
    {
        public HelloWorldRegistry()
        {
            Routes.HomeIs<HomeInputModel>()
                .IgnoreControllerNamespaceEntirely();
        }
    }


the views (Razor)

Home.cshtml

@model Aims.HomeViewModel

@{
    Layout = "Application";
}

<h2>Home</h2>

List.cshtml

@model Aims.ListViewModel

@{
    Layout = "Application";
}

<h2>List</h2>

The problem I am having is
if I have

Routes.IgnoreControllerNamespaceEntirely();

I get the routes

(default)

home/list


The route / works
The /home/list throws


Line 44:         protected ASP.global_asax ApplicationInstance {
Line 45:             get {
Line 46:                 return ((ASP.global_asax)(Context.ApplicationInstance));
Line 47:             }
Line 48:         }

/home/index also throws the same error.

If I don't set any routing constraints or have Routes.HomeIs<HomeInputModel>();
I get routes

(default)

test/home/list


The route / works
The route /test/home/list works
the route /test/home/index returns HTTP Error 404.0 - Not Found

Is the above expected behavior, why the different responses on namepaced vs none namespaced home/index
Also is I don't set the default home route why can't I get to the the action using full url? Why can't I get to the home route using the full url?

How can I fix the error for when I use IgnoreControllerNamespaceEntirely(), Maybe I am missing a config?

Jeremy D. Miller

unread,
Apr 22, 2013, 1:14:14 PM4/22/13
to fubumv...@googlegroups.com
Nothing is jumping out at me here.  Have you tried using diagnostics on this to see what the routes really come out as?

The route determination is what I'd expect to happen.  Once you make an endpoint the default route, the pattern is an empty string.  The second route to /home/index doesn't exist.

I have no idea what the exception is that you're getting:(


In Josh & I's projects we generally use the url patterns for:

get_something_something_Property()
post_something_Property(model)




--
You received this message because you are subscribed to the Google Groups "FubuMVC Development Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fubumvc-deve...@googlegroups.com.
To post to this group, send email to fubumv...@googlegroups.com.
Visit this group at http://groups.google.com/group/fubumvc-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Namith

unread,
Apr 22, 2013, 3:21:43 PM4/22/13
to fubumv...@googlegroups.com
Sorry I forgot the error is a compilation error during view building
I am not sure whether the application instance should be fubu instance or its an error on razor only

Sorry for the huge paste

The name 'Context' does not exist in the current context


Line 1:    #pragma checksum ".......\Test\home.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "C92FE1F4231412933A8EA79DCBAE2565C9CF5C8E"
Line 2:    //------------------------------------------------------------------------------
Line 3:    // <auto-generated>
Line 4:    //     This code was generated by a tool.
Line 5:    //     Runtime Version:4.0.30319.18034
Line 6:    //
Line 7:    //     Changes to this file may cause incorrect behavior and will be lost if
Line 8:    //     the code is regenerated.
Line 9:    // </auto-generated>
Line 10:   //------------------------------------------------------------------------------
Line 11:   
Line 12:   namespace ASP {
Line 13:       using System;
Line 14:       using System.Collections.Generic;
Line 15:       using System.IO;
Line 16:       using System.Linq;
Line 17:       using System.Net;
Line 18:       using System.Web;
Line 19:       using System.Web.Helpers;
Line 20:       using System.Web.Security;
Line 21:       using System.Web.UI;
Line 22:       using System.Web.WebPages;
Line 23:       using FubuMVC.Core;
Line 24:       using FubuCore;
Line 25:       using FubuCore.Reflection;
Line 26:       using FubuLocalization;
Line 27:       using FubuMVC.Core.UI;
Line 28:       using FubuMVC.Core.Assets;
Line 29:       using FubuMVC.Core.View;
Line 30:       using FubuMVC.Razor;
Line 31:       using HtmlTags;
Line 32:       using WebMatrix.Data;
Line 33:       using WebMatrix.WebData;
Line 34:       
Line 35:       
Line 36:       public class _Page_home_cshtml : FubuMVC.Razor.Rendering.FubuRazorView<Test.HomeViewModel> {
Line 37:           
Line 38:   #line hidden
Line 39:   
Line 40:           
Line 41:           public _Page_home_cshtml() {
Line 42:           }
Line 43:           
Line 44:           protected ASP.global_asax ApplicationInstance {
Line 45:               get {
Line 46:                   return ((ASP.global_asax)(Context.ApplicationInstance));
Line 47:               }
Line 48:           }
Line 49:           
Line 50:           public override void Execute() {
Line 51:   
Line 52:   WriteLiteral("\r\n");
Line 53:   
Line 54:   
Line 55:               
Line 56:               #line 3 ".......\Test\home.cshtml"
Line 57:     
Line 58:       Layout = "Application";
Line 59:   
Line 60:   
Line 61:               
Line 62:               #line default
Line 63:               #line hidden
Line 64:   WriteLiteral("\r\n<h2>Home</h2>\r\n");
Line 65:   
Line 66:   
Line 67:           }
Line 68:       }
Line 69:   }
Line 70:   

Namith

unread,
Apr 22, 2013, 3:44:18 PM4/22/13
to fubumv...@googlegroups.com
Ok changed the endpoint actions to be Get_Home_Index and Get_Home_List
removed any route configs and now diagnostics shows both routes home/index and home/list
both behaviors point to the right place

HomeEndpoint.Get_Home_Index()
OutputNode

HomeEndpoint.Get_Home_List()
OutputNode

but accessing both url's throws the previously mentioned view compilation error

Jeremy D. Miller

unread,
Apr 22, 2013, 3:46:32 PM4/22/13
to fubumv...@googlegroups.com
Let's get Corey to look at this one.  This might be a missing Razor or System.Web.* assembly reference maybe.


Namith

unread,
Apr 22, 2013, 3:47:36 PM4/22/13
to fubumv...@googlegroups.com
Adding some context. Trying to follow this post http://coreykaylor.com/blog/2012/11/17/getting-started-with-fubumvc-again which doesnt use the webactivator to setup the app

Jeremy D. Miller

unread,
Apr 22, 2013, 3:50:43 PM4/22/13
to fubumv...@googlegroups.com
WebActivator isn't very important.  It's just a shim to avoid writing a tiny bit of code directly in Global.asax.  I don't think that has any impact on the Razor problem you're seeing.




On Apr 22, 2013, at 2:47 PM, Namith <namt...@gmail.com> wrote:

Adding some context. Trying to follow this post http://coreykaylor.com/blog/2012/11/17/getting-started-with-fubumvc-again which doesnt use the webactivator to setup the app

Namith

unread,
Apr 22, 2013, 4:01:10 PM4/22/13
to fubumv...@googlegroups.com
Sorry I did not mean that webactivator has something to do with the error. I was trying to set the context on why I was not using the easy startup nuget. which sets up everything by default. Which I was using before and had no issues

Namith

unread,
Apr 27, 2013, 7:17:04 PM4/27/13
to fubumv...@googlegroups.com
Any pointers on this guys? I have not been able to figure it out yet.

Artem Smirnov

unread,
Apr 28, 2013, 7:35:18 AM4/28/13
to fubumv...@googlegroups.com
You say compilation error, but what's the exception message?

As for the 404's, can you try and set different input model types for your action methods? It's not mandatory, but who knows?

Namith

unread,
Apr 28, 2013, 11:53:36 AM4/28/13
to fubumv...@googlegroups.com
The name 'Context' does not exist in the current context

Artem Smirnov

unread,
Apr 28, 2013, 1:03:15 PM4/28/13
to fubumv...@googlegroups.com
Looks like it's a Razor problem.. Do you have the autogenerated code that the engine should provide when throwing an exception like this? Looking at it (ot trying to compile it), you can figure out the problem.

Namith

unread,
Apr 28, 2013, 6:04:55 PM4/28/13
to fubumv...@googlegroups.com
Its on the Third post

Corey Kaylor

unread,
Apr 28, 2013, 6:34:57 PM4/28/13
to fubumv...@googlegroups.com
Any chance you can post the code somewhere? It's hard for me to speculate what's going on.


Artem Smirnov

unread,
Apr 29, 2013, 2:53:12 AM4/29/13
to fubumv...@googlegroups.com
Sorry, missed it.

The problem is that Visual Studio assumes that you inherit your View from System.Web.WebPages.WebPageBase (I think), which does have a Context property indeed. Why it thinks so, I wouldn't know. FubuRazorView doesn't have this property, and I don't know how to fix it without changing the source (and sending a pull request).

Namith

unread,
Apr 29, 2013, 11:49:34 AM4/29/13
to fubumv...@googlegroups.com
Ive attached the project
Test.zip

Namith

unread,
Apr 29, 2013, 11:50:14 AM4/29/13
to fubumv...@googlegroups.com
Ive attached the project

On Sunday, April 28, 2013 5:34:57 PM UTC-5, Corey wrote:
Test.zip

Namith

unread,
Apr 29, 2013, 11:52:31 AM4/29/13
to fubumv...@googlegroups.com
Ive attached the project

On Sunday, April 28, 2013 5:34:57 PM UTC-5, Corey wrote:
Test.zip

Namith

unread,
Apr 29, 2013, 11:57:50 AM4/29/13
to fubumv...@googlegroups.com
Sorry for the multiple posts.
I swear I kept getting an alert that there was an error and to try again!

Namith

unread,
May 13, 2013, 12:15:55 PM5/13/13
to fubumv...@googlegroups.com
Hello guys

I still haven't been able to figure this out, as far i can tell its a razor thing. So I have a question,
Is it recommended to best go with spark on fubu or are both view engines going to be supported equally?

Gary L Cox Jr

unread,
May 13, 2013, 12:22:00 PM5/13/13
to fubumv...@googlegroups.com
I'm coming into this late and forgive me if I didn't see someone answer this higher up in the chain.  But looking at your first post, within your FubuRegistration i'm not seeing your entry for Actions which informs fubu how to get your endpoint action calls.  Are you actually seeing routes in Fubu Diagnostics?

You should have something similar to:

Actions.FindBy(a => { 
    a.Applies.ToThisAssembly();
    // Other assemblies like a.Applies.ToAssemblyContainingType<CoreMarker>() // your core project
    a.IncludeClassesSuffixedWithController();
});

Gary L Cox Jr

unread,
May 13, 2013, 12:26:38 PM5/13/13
to fubumv...@googlegroups.com
Since your using Endpoint and not Controller, replace IncludeClassesSuffixedWIthController() and use IncludeClassesSuffixedWithEndpoint()

Jeremy D. Miller

unread,
May 13, 2013, 1:08:47 PM5/13/13
to fubumv...@googlegroups.com
Gary,

Just so everyone knows, you don't have to specify action discovery.  Out of the box, FubuMVC matches inside the assembly containing the FubuRegistry for classes suffixed with "Endpoint" or "Endpoints"

- Jeremy

Artem

unread,
May 13, 2013, 1:22:08 PM5/13/13
to fubumv...@googlegroups.com
Why does a View inherit from System.Web.WebPages.WebPageBase ? Is it a Fubu thing? I suspect MS MVC uses a different base class (don't remember which one).

Artëm Smirnov
http://about.me/ulu

Chpokk, online C# code editor
http://chpokk.apphb.com/


2013/5/13 Jeremy D. Miller <jeremy...@yahoo.com>

--
You received this message because you are subscribed to a topic in the Google Groups "FubuMVC Development Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fubumvc-devel/ASwgJePBoNg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to fubumvc-deve...@googlegroups.com.

Ryan Rauh

unread,
May 13, 2013, 3:08:04 PM5/13/13
to FubuMVC Development Group
Which view engine are you using? 

Artem Smirnov

unread,
May 16, 2013, 6:00:40 AM5/16/13
to fubumv...@googlegroups.com
Sorry, I wasn't clear. I think Namith is having this problem because the autogenerated code contains a reference to the Context property, which is because Razor assumes that the View inherits from System.Web.Mvc.WebViewPage ,which is the case if you use MS MVC. However, Fubu's Razor view inherits from FubuRazorView, which doesn't have this property. Adding it would solve the problem.

Mike

unread,
May 21, 2013, 3:43:19 PM5/21/13
to fubumv...@googlegroups.com
It definitely appears to be something with regards to the interaction between whatever project setup is already in place and Fubu using Razor as I was able to successfully get Fubu/Razor to work in a separate solution/project.

Here is the generated code:

Line 2:    //------------------------------------------------------------------------------
Line 3:    // <auto-generated>
Line 4:    //     This code was generated by a tool.
Line 5:    //     Runtime Version:4.0.30319.18047
Line 6:    //
Line 7:    //     Changes to this file may cause incorrect behavior and will be lost if
Line 8:    //     the code is regenerated.
Line 9:    // </auto-generated>
Line 10:   //------------------------------------------------------------------------------
Line 11:   
Line 12:   namespace ASP {
Line 13:       using System;
Line 14:       using System.Collections.Generic;
Line 15:       using System.IO;
Line 16:       using System.Linq;
Line 17:       using System.Net;
Line 18:       using System.Web;
Line 19:       using System.Web.Helpers;
Line 20:       using System.Web.Security;
Line 21:       using System.Web.UI;
Line 22:       using System.Web.WebPages;
Line 23:       using FubuMVC.Core;
Line 24:       using FubuCore;
Line 25:       using FubuCore.Reflection;
Line 26:       using FubuLocalization;
Line 27:       using FubuMVC.Core.UI;
Line 28:       using FubuMVC.Core.Assets;
Line 29:       using FubuMVC.Core.View;
Line 30:       using FubuMVC.Razor;
Line 31:       using HtmlTags;
Line 32:       
Line 33:       
Line 34:       public class _Page_contentdashboard_courses_cshtml : FubuMVC.Razor.Rendering.FubuRazorView<PS.Web.Dashboards.ContentDashboard.CoursesVm> {
Line 35:           
Line 36:   #line hidden
Line 37:   
Line 38:           
Line 39:           public _Page_contentdashboard_courses_cshtml() {
Line 40:           }
Line 41:           
Line 42:           protected ASP.global_asax ApplicationInstance {
Line 43:               get {
Line 44:                   return ((ASP.global_asax)(Context.ApplicationInstance));
Line 45:               }
Line 46:           }
Line 47:           
Line 48:           public override void Execute() {
Line 49:   
Line 50:   WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html>\r\n<head>\r\n    <title>Hello</title>\r\n</head>\r\n<body>\r\n " +
Line 51:   "   <h1>Hello</h1>\r\n    <div>\r\n\r\n    </div>\r\n</body>\r\n</html>\r\n");
Line 52:   
Line 53:   
Line 54:           }
Line 55:       }
Line 56:   }

On Tuesday, May 21, 2013 1:07:22 PM UTC-6, Mike wrote:
I'm running into this same issue with Razor.  The view has been striped down to not even reference the model.  

Note that I'm adding FubuMvc to a project that is already doing WebForms and ASP.NET MVC 3 (with Razor).  Not sure if that is causing the issue.  Was there ever a resolution to the issue reported here?  Will do some more investigation.


Compiler Error Message: CS0103: The name 'Context' does not exist in the current context

Source Error:

Line 42:         protected ASP.global_asax ApplicationInstance {
Line 43:             get {
Line 44:                 return ((ASP.global_asax)(Context.ApplicationInstance));
Line 45:             }
Line 46:         }

Artem Smirnov

unread,
May 22, 2013, 5:08:11 AM5/22/13
to fubumv...@googlegroups.com
Weird, I just got the same error with a pure Fubu project. I've just created an empty app and added FubuMVC.QuickStart and FubuMVC Razor NuGets. View is empty except for the @model directive.

Mike

unread,
May 23, 2013, 11:26:22 AM5/23/13
to fubumv...@googlegroups.com
So... suddenly it started working.  Unfortunately because it's not really possible to share even Razor views between the two so we're going to abandon it for now... hopefully we'll be able to come back to it later and try again.

Corey Kaylor

unread,
May 23, 2013, 11:31:20 AM5/23/13
to fubumv...@googlegroups.com
Sorry I couldn't help respond to this sooner. I've been on vacation for a while now and just got back in today. Sorry to hear that sharing views between the two is a show stopper.


--

Mike

unread,
May 23, 2013, 11:35:59 AM5/23/13
to fubumv...@googlegroups.com
Specifically we want to share the base layout (not whole views).  We also couldn't get partials to work?  Documentation is still a barrier to adoption... :(

Corey Kaylor

unread,
May 23, 2013, 11:41:06 AM5/23/13
to fubumv...@googlegroups.com
You should be able to share the base layout depending on whether or not you're using aspmvc specific code blocks or not. Partials should also work, but fubu requires the file to be prefixed with _. That could probably be customized if / when you come back to it again.


On Thu, May 23, 2013 at 9:35 AM, Mike <dark...@gmail.com> wrote:
Specifically we want to share the base layout (not whole views).  We also couldn't get partials to work?  Documentation is still a barrier to adoption... :(

Namith

unread,
May 23, 2013, 11:48:03 AM5/23/13
to fubumv...@googlegroups.com
@Mike
Do you know what you did to make it work. I never could make it work. You might want to checkout juniorRoute for the time being it might fit with what you are wanting to do.
I would appreciate pointers as to what fixed it for you.

Jeremy D. Miller

unread,
May 23, 2013, 11:53:43 AM5/23/13
to fubumv...@googlegroups.com
Spark is more mature on FubuMVC because that's the most commonly used view engine for our community for historical reasons.

As for Razor, I think the answer has to be that we the fubu core team need to start using Razor in anger on real projects (there are other reasons too) to get through these issues.  I do think Razor is a little more environmentally sensitive than Spark as well.

And yes, the docs issue is a big problem but that's starting to improve behind the scenes.

- Jeremy


Reply all
Reply to author
Forward
0 new messages