This project is read-only.
2

Closed

A parameter is mysteriously appended to url on root of application

description

All of a sudden today I'm getting an "Area" appended to the query string on the root of my application. It doesn't show up outside of the root. Asp.Net MVC 5 using attribute routing. No default routes are specified at all in my app. All controller actions have a manual route applied using an attribute.

How do I get rid of this extra parameter?
Url.Action(MVC.Product.Detail(x, y, z)) 
produces the following url:

http://test.localtest.me/product/27573/harry-potter-and-the-sorcerers-stone?Area=
Closed Jan 28, 2015 at 4:10 PM by KevinKuszyk
As part of our move to GitHub, we are closing all the outstanding issues on CodePlex.

If your issue is still valid, please re-open it on GitHub:
https://github.com/T4MVC/T4MVC/issues

Thanks for contributing!

comments

davidebbo wrote Feb 9, 2014 at 9:17 PM

JoeyBradshaw wrote Feb 10, 2014 at 9:47 AM

I don't have any areas. I tried all the suggested fixes and these were the results:
  1. Add dummy Area: fixed the issue on the root page, but severely broke links on all other pages.
  2. Registered a default route (non-attribute based) with an empty value for Area: had no affect on the issue.
    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", area = "", id = UrlParameter.Optional }
    );
  1. Modified T4MVC.tt (T4MVC Version 3.7.4): this fixed the issue for me. No artifacts or broken urls on any pages now.
Added the following method to deal with unwanted route values at line 205.
        protected void RemoveRouteValueIfNullOrWhiteSpace(string key, RouteValueDictionary routeValues)
        {
            if (routeValues.ContainsKey(key) && string.IsNullOrWhiteSpace(routeValues[key].ToString()))
                routeValues.Remove(key);
        }
Added call to remove empty Area route value at line 355. There may be another spot in the template where this call is needed, but I haven't run into it yet.
    RemoveRouteValueIfNullOrWhiteSpace("Area", callInfo.RouteValueDictionary);
Thanks for pointing me in the right direction.

davidebbo wrote Feb 10, 2014 at 10:30 PM

Can you be more specific how the links were broken when adding a dummy area?