Sample ASP.NET Core 6.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
860 B

using System.Text.RegularExpressions;
namespace Microsoft.eShopWeb.FunctionalTests.Web;
public static class WebPageHelpers
{
public static string TokenTag = "__RequestVerificationToken";
public static string GetRequestVerificationToken(string input)
{
string regexpression = @"name=""__RequestVerificationToken"" type=""hidden"" value=""([-A-Za-z0-9+=/\\_]+?)""";
return RegexSearch(regexpression, input);
}
public static string GetId(string input)
{
string regexpression = @"name=""Items\[0\].Id"" value=""(\d)""";
return RegexSearch(regexpression, input);
}
private static string RegexSearch(string regexpression, string input)
{
var regex = new Regex(regexpression);
var match = regex.Match(input);
return match.Groups.Values.LastOrDefault().Value;
}
}