Question

This wasnt happening before but all of a sudden I am not hitting my default route anymore. My homepage goes to http://localhost:2222/assets/images/30?Controller=home&Action=index. Why would this be happening?

I noticed when I am in a action on the home controller it works fine, but if I go to another controller this problem occurs.

@foreach(var t in MVC.Home.Index().GetRouteValueDictionary())
    {
        <span>@t.Key - @t.Value</span>
    }

Area - Controller - home Action - index

Link

@Html.ActionLink("Home", MVC.Home.Index())

Global.asax

 routes.Add(
                "Images",
                new Route(
                    "assets/images/{Id}",
                        new RouteValueDictionary(),
                        new RouteValueDictionary { { "Id", "\\d+" } },
                        new ImageRouteHandler(new ImageHandler())
                    )
                );


            routes.MapRouteLowercase(
               "Default",


                  "{controller}/{action}",


                   new { controller = "Home", action = "Index", area="" }
                   );

HomeController.cs

public partial class HomeController : SiteController


     {
          public virtual ActionResult Index()
                {
                    var model = new HomeViewModel();


                    return View(model);
                }

T4MVC.cs

   public class ActionNamesClass {
            public readonly string Index = ("Index").ToLowerInvariant();
}
Was it helpful?

Solution

I went ahead and reversed the default route, and assets route and everything is working, weird.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top