c#MVC控制器被命中,即使未在URL中指定区域

问题描述 投票:0回答:1

URL中未指定区域时,我的控制器被击中:

https://localhost:441/wholesale_signup,它将找不到该视图并抛出错误。

如何防止该控制器首先被打到只有404s?

仅在提供区域和控制器时才应点击:https://localhost:441/customerservice/wholesale_signup

asp.net-mvc routing
1个回答
0
投票

所以我想我不确定如何表达我的问题,但是经过几个小时的搜索,我找到了解决方案:

ASP.NET MVC 2 RC 2 returns Area-specific controller when no area specified

routes.MapRouteLowercase(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new[] { "Default.Controller.Namespace" }
).DataTokens["UseNamespaceFallback"] = false; ;
© www.soinside.com 2019 - 2024. All rights reserved.