Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MVC URL模式中的OR运算符_C#_Asp.net Mvc_Asp.net Mvc Routing - Fatal编程技术网

C# MVC URL模式中的OR运算符

C# MVC URL模式中的OR运算符,c#,asp.net-mvc,asp.net-mvc-routing,C#,Asp.net Mvc,Asp.net Mvc Routing,我正在写一个MVC路线,我想知道,我可以在其中使用类似OR操作符的东西吗 像这样,我的URL可以以“shop/”或“articles/”开头 可以使用管线约束来指定由管道分隔的有效值 routes.MapRoute( name: "Default", url: "{page}/{action}/{id}", defaults: new { controller = "Store", action = "Index", id = UrlParameter.Optional },

我正在写一个MVC路线,我想知道,我可以在其中使用类似OR操作符的东西吗

像这样,我的URL可以以“shop/”或“articles/”开头


可以使用管线约束来指定由管道分隔的有效值

routes.MapRoute(
   name: "Default",
   url: "{page}/{action}/{id}",
   defaults: new { controller = "Store", action = "Index", id = UrlParameter.Optional },
   constraints: new { page = "shop|articles" });

可以使用管线约束来指定由管道分隔的有效值

routes.MapRoute(
   name: "Default",
   url: "{page}/{action}/{id}",
   defaults: new { controller = "Store", action = "Index", id = UrlParameter.Optional },
   constraints: new { page = "shop|articles" });

假设您已经阅读了,您的问题应该是“如何构建接受两个字符串之一的正则表达式”。。。如果你不知道这个特性,那么这个问题与我认为的@AlexeiLevenkov类似,这个问题不需要改变。假设你已经读过,你的问题应该是“如何构建接受两个字符串之一的正则表达式”。。。如果你不知道这个特性,那么这个问题就是我认为在这个例子中@AlexeiLevenkov的重复问题,这个问题不需要改变Hanks Henk。我看过很多例子,但不知何故,它们都没有向我展示任何关于约束的内容。谢谢Henk。我看过很多例子,但不知何故,它们都没有向我展示任何约束。