コントローラのアクション/ルート)にリダイレクトされます。 HttpModuleを使うととても簡単です。私の次のサンプルコードを見てください。もっとINFOMATIONについては
グローバルweb.configファイルで
<configuration>
<system.web>
<httpModules>
<add name="RedirectModule" type="MySolution.RedirectModule, MySolution" />
</httpModules>
</system.web>
<!-- The following code will be used by IIS 7+ -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="RedirectModule" />
<add name="RedirectModule" type="MySolution.RedirectModule MySolution" />
</modules>
</system.webServer>
</configuration>
MySolution/RedirectModule.csで
using System;
using System.Web;
namespace MySolution
{
public class RedirectModule : IHttpModule
{
#region IHttpModule Members
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(HttpApplication_BeginRequest);
}
public void Dispose() {}
#endregion
void HttpApplication_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
if (*[logic for checking before redirect]*)
{
app.Response.Redirect(*[url]*);
}
}
}
}
、UrlRewritingNet.UrlRewriteのようなURLマッピングのソースコードを見てください。
PS。 IHttpModuleは非常に強力なインターフェイスです。それはすべての要求タイプで処理できます。それで、私はこの質問を完全に解決するのに役立ちます。
答えがある場合は、なぜ質問していますか? – Avitus
私は何の答えもありません。アイデアはありますか? –