我想使用正则表达式检查而不是
if( actionContext.Request.RequestUri.AbsolutePath == "/api/v1/token")
使用类似的东西:
Regex rgx = new Regex(@"/api/v1/token");
不仅匹配v1,还匹配v2、v3、v4等等……
if(rgx. actionContext.Request.RequestUri.AbsolutePath.isMatch){
//then do further actions
}
请您参考如下方法:
Regex rgx = new Regex("^\/api\/v[1234]\/token$");
if(rgx.IsMatch(actionContext.Request.RequestUri.AbsolutePath)){
//then do further actions
}
