private string GetRedirect(string badRequest)
    {
        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"pages/(\d+)$", (System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.IgnoreCase));
        System.Text.RegularExpressions.MatchCollection matches = regex.Matches(badRequest);
        if (matches.Count > 0)
        {
            string id = matches[0].Value.Replace("pages/", "");
            int aId;
            try
            {
                aId = Int32.Parse(id);
                return "http://localhost:1731/web/pages/room.aspx?id=" + id;
            }
            catch
            {

            }
        }
        return badRequest;
    }
    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        string originalUrl = Request.Url.ToString();
        string newUrl = GetRedirect(originalUrl);
        if (newUrl != originalUrl)
        {
            System.Uri myUri = new Uri(newUrl);
            Context.RewritePath(myUri.PathAndQuery);
        }

    }

相关文章:

  • 2021-07-24
  • 2022-01-04
  • 2022-12-23
  • 2021-10-14
  • 2021-09-23
  • 2021-04-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-03-10
相关资源
相似解决方案