MarkItUp.SingleUserBlog/UI/Redirector.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.IO;
using MarkItUp.SingleUserBlog.Common;
namespace MarkItUp.SingleUserBlog.UI {
/*
*
* This class only exists so that I can create Url mappings to pages that are external to my own site.
*
* The UrlMappings service that comes with ASP.NET does not allow mappings to external pages.
*
* This Handler is *very* untested so use it at your own peril. I simply use it to redirect my main RSS feed
* to my Feedburner feed. Anything more hard-core than that and it's at your own risk ok! :-)
*
*/
public class Redirector : IHttpHandler {
public bool IsReusable {
get { return false; }
}
public void ProcessRequest(HttpContext context) {
string mappingFile = context.Server.MapPath("~/App_Data/UrlMappings.xml") ;
if (File.Exists(mappingFile)) {
XmlDocument xml = new XmlDocument();
xml.Load(mappingFile);
Control foo = new Control();
string rawUrl = context.Request.RawUrl.ToLower() ;
XmlNodeList mappings = xml.DocumentElement.SelectNodes("//UrlMapping");
for (int i = 0; i < mappings.Count; i++) {
string url = foo.ResolveUrl(mappings[i].Attributes["url"].Value).ToLower();
if (rawUrl.StartsWith(url)) {
string mappedUrl = mappings[i].Attributes["mappedUrl"].Value;
context.Response.Redirect(mappedUrl);
}
}
}
}
后面还有 7 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
