Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... android.intent.action.SCREEN_ON & android.intent.action.SCREEN_OFF First, I've tried create a receiver to receive screen on/off and register receiver on AndroidManifest.xml like below, but unfortunately ... LogonUser Function : impersonate a windows user // This sample demonstrates the use of the WindowsIdentity class to impersonate a user. // IMPORTANT NOTES:  // This sample can be run only ...
Stats
Url rewrite using IHttpModule
UrlRewriter.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

/// <summary>
/// UrlRewriter 的摘要描述
/// </summary>
namespace idv.modules
{
    public class UrlRewriter : IHttpModule
    {

        #region IHttpModule 成員

        public void Dispose()
        {
            //throw new NotImplementedException();
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            HttpContext context = application.Context;

            if (context.Request.Path.EndsWith("TranslatedPage.html", StringComparison.CurrentCultureIgnoreCase))
            {
                string currentUrl = context.Request.Path;

                // rewrite url [http://www.domain.com/actionValue/TranslatedPage.html]
                // to [http://www.domain.com/TranslatedPage.aspx?action=actionValue]
                string action = Regex.Match(currentUrl, "/([^/]+)/TranslatedPage.html", RegexOptions.IgnoreCase).Groups[1].Value;
                context.RewritePath("~/TranslatedPage.aspx?action=" + action);
            }
        }

        #endregion
    }
}
Web.config
<httpModules>
    <add name="UrlRewriter" type="idv.modules.UrlRewriter"/>
</httpModules>