是否可以 - 最好的做法 - 使用第二层重定向用户?
例如:
public static void ForceLogin()
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName];
if (cookie != null)
{
if (Regex.IsMatch(cookie.Value, "^[0-9]+\\.[a-f0-9]+$"))
{
using (EibxDataContext db = new EibxDataContext())
{
int count = db.Logins.Count(l => l.Password == cookie.Value);
if (count == 1)
{
return;
}
}
}
}
HttpContext.Current.Response.Redirect("~/Login.aspx");
}
Run Code Online (Sandbox Code Playgroud)
在最后一行,我使用业务/服务逻辑层将用户重定向到登录页面.
这应该在Presentation层中完成吗?
我正在尝试将以下字符串分为三组.
0:0:Awesome:awesome
Run Code Online (Sandbox Code Playgroud)
那是" 0 "," 0 "和" 真棒:太棒了 "
使用此正则表达式:
^([0-9]+)\:([0-9]*)\:(.*)$
Run Code Online (Sandbox Code Playgroud)
它适用于在线正则表达式服务:http://rubular.com/r/QePxt57EwU
但似乎.NET不同意. 来自Visual Studio http://xs.to/image-3F8A_4BA916BD.jpg的正则表达式问题的图片