温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:
SpaceBuider11/BlogControls/HttpHandler/ShortLink.cs,打开代码结构图
SpaceBuider11/BlogControls/HttpHandler/ShortLink.cs,打开代码结构图
//------------------------------------------------------------------------------
// <copyright company="Tunynet">
// Copyright (c) Tunynet Inc. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using SpaceBuilder.Blogs.Components;
using SpaceBuilder.Components;
namespace SpaceBuilder.Blogs.Controls
{
/// <summary>
/// 处理通过短链接方式访问博客文章
/// </summary>
/// <example>
/// 博客文章一般通过: http://www.spacebuilder.cn/u/WOAI2006/Blog/archive/2008/04/02/959.aspx,
/// 通过<c>ShortLink</c>可以实现http://www.spacebuilder.cn/u/WOAI2006/Blog/ShortLink.ashx?PostID=959方式访问
/// </example>
public class ShortLink : System.Web.IHttpHandler
{
#region IHttpHandler Members
/// <summary>
/// 对短链接重定向到正在链接
/// </summary>
public void ProcessRequest(System.Web.HttpContext context)
{
if (context.Request.QueryString["PostID"] != null)
{
int postID = Int32.Parse(context.Request.QueryString["PostID"]);
BlogThread blogThread = BlogPosts.GetThread(postID, false);
if (blogThread != null)
context.Response.Redirect(BlogUrls.Instance().ShowPost(blogThread, blogThread.Weblog), true);
}
context.Response.Redirect(ChannelUrls.Instance().BlogHome(), true);
}
/// <exclude/>
public bool IsReusable
{
get { return false; }
}
#endregion
}
}
