/// <summary> /// 重写Url /// </summary> /// <param name="sender">事件的源</param> /// <param name="e">包含事件数据的 EventArgs</param> private void ReUrl_BeginRequest(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; //url重写 UrlRewriter.Rewrite(context); }
public void UrlRewriterUtilityReturnsSuccessForFormActionSingleQuote(string fromUrl, string toUrl) { // arrange string content = $"<div><form action='http://no-change/abcdef' /><form action='{fromUrl}/abcdef' /></div>"; string expectedResult = $"<div><form action='http://no-change/abcdef' /><form action='{toUrl}/abcdef' /></div>"; // act var result = UrlRewriter.Rewrite(content, new Uri(fromUrl, UriKind.RelativeOrAbsolute), new Uri(toUrl, UriKind.Absolute)); // assert A.Equals(result, expectedResult); }
public void UrlRewriterUtilityReturnsSuccessForAnchorLinkDoubleQuote(string fromUrl, string toUrl) { // arrange string content = $"<div><a href=\"http://no-change/abcdef\">linky</a><a href=\"{fromUrl}/abcdef\"></div>"; string expectedResult = $"<div><a href=\"http://no-change/abcdef\">linky</a><a href=\"{toUrl}/abcdef\"></div>"; // act var result = UrlRewriter.Rewrite(content, new Uri(fromUrl, UriKind.RelativeOrAbsolute), new Uri(toUrl, UriKind.Absolute)); // assert A.Equals(result, expectedResult); }