C# MVC查询字符串参数未传递到操作

C# MVC查询字符串参数未传递到操作,c#,asp.net-mvc,C#,Asp.net Mvc,我有以下行动: public ActionResult CatchAll(字符串路径名,bool-isPreview) { CatchAllModel=\u aliasModelBuilder.BuildCatchAllModel(路径名,isPreview); 如果(model.Page!=null) { 返回视图(模型); } 其他的 { 抛出新的HttpException(404,“未找到页面”); } } 这条路线是 routes.MapRoute( 名称:“默认”, url:“{*路

我有以下行动:

public ActionResult CatchAll(字符串路径名,bool-isPreview)
{
CatchAllModel=\u aliasModelBuilder.BuildCatchAllModel(路径名,isPreview);
如果(model.Page!=null)
{
返回视图(模型);
}
其他的
{
抛出新的HttpException(404,“未找到页面”);
}
}
这条路线是

routes.MapRoute(
名称:“默认”,
url:“{*路径名}”,
默认值:新建{controller=“Alias”,action=“CatchAll”,isPreview=false});
现在,如果我浏览到
localhost/about-us?isPreview=true
,路径名显示为
about-us
,但
isPreview
显示为false


是否有什么我做错了-我认为路由默认值应该被查询字符串覆盖

Ok这看起来好像路由中设置的默认参数没有被查询字符串覆盖。因此,我将其从路线中删除:

routes.MapRoute(
    name: "Default",
    url: "{*pathname}",
    defaults: new { controller = "Alias", action = "CatchAll" });
并将其添加到操作中:

public ActionResult CatchAll(string pathname, bool isPreview = false)

我想我必须抑制CA1026,因为我们不能为操作创建重载方法。这看起来好像路由中设置的默认参数没有被querystring覆盖。因此,我将其从路线中删除:

routes.MapRoute(
    name: "Default",
    url: "{*pathname}",
    defaults: new { controller = "Alias", action = "CatchAll" });
并将其添加到操作中:

public ActionResult CatchAll(string pathname, bool isPreview = false)
我想我将不得不抑制CA1026,因为我们无法为操作创建重载方法