This project is read-only.

possible bugs

Jul 27, 2012 at 12:53 PM

recently i am working with mvc4 rc, and i meet some problems.

1, Url.Action(ActionResult) doesn't generate lower case area names even when i set UserLowercaseRoutes to true.

but it just works fine for controller and action names.

2, MVC.AreaName.Home.Index() always genertes T4MVC_ActionResult.


Jul 27, 2012 at 1:02 PM

sorry, the second problem is my false.

i should use Url.Action(MVC.AreaName.Home.Index()) instead of MVC.AreaName.Home.Index().

MVC.AreaName.Home.Index() is an object of T4MVC_ActionResult, so the type name becomes a literal text while rendering the view.

Jul 27, 2012 at 1:25 PM
Edited Jul 27, 2012 at 1:38 PM

just now i tried to debug the view and i found that route values in dictionary are all lowered.
but in the final rendered html, it fell back to capitalized.

maybe it's just a feature of mvc4.

Jul 27, 2012 at 9:22 PM

now i know that mvc4 always overwrite the areaName if using areas.
here's the code from System.Web.Mvc.RouteCollectionExtensions:

        internal static VirtualPathData GetVirtualPathForArea(this RouteCollection routes, RequestContext requestContext, string name, RouteValueDictionary values, out bool usingAreas)
            if (routes == null)
                throw new ArgumentNullException("routes");
            if (!string.IsNullOrEmpty(name))
                usingAreas = false;
                return routes.GetVirtualPath(requestContext, name, values);
            string areaName = null;
            if (values != null)
                object obj2;
                if (values.TryGetValue("area", out obj2))
                    areaName = obj2 as string;
                else if (requestContext != null)
                    areaName = AreaHelpers.GetAreaName(requestContext.RouteData);
            RouteValueDictionary dictionary = values;
            RouteCollection route. = FilterRouteCollectionByArea(routes, areaName, out usingAreas);
            if (usingAreas)
                dictionary = new RouteValueDictionary(values);
            return route..GetVirtualPath(requestContext, dictionary);

the bold text is the key point. it's totally out of control of T4MVC.

Jul 27, 2012 at 9:27 PM

Catching up on this thread. So is there anything left that needs to be discussed as a T4MVC thing, or is everything explained outside of it?

Jul 30, 2012 at 9:43 PM

now just one thing. is Url.Action(ActionResult) possible to produce url with real lowercase area name as a return value?

of course i can extract the area name, lowercase it, and then rebuild the url in Url.Action(ActionResult), or just manually lowercase every area name in RouteMap, but they don't look perfect.

so is there any mechanism or trick to achieve?

Jul 30, 2012 at 10:28 PM

I think that even outside T4MVC, the MVC framework makes the casing of the area token the same as the area name. In the end, T4MVC is just a wrapper over MVC, so it inherits this behavior.

There are various things you can do to make your routes lower case. e.g. see But they are outside the scope of T4MVC.