Ah to solving this problem, my mind is completely busy. When i register my httpmodule, I get not-found error, otherwise everything works like a charm.
Here is my httpmodule
public class UrlNormalizerModule : HttpModuleBase {
protected override void OnBeginRequest(HttpContextBase context) {
var originUrl = HttpContext.Current.Request.Url.ToString();
var normalizedUrl = originUrl.NormalizeUrl(false);
if (string.Compare(originUrl, normalizedUrl) != 0) {
var response = context.Response;
response.StatusCode = (int) HttpStatusCode.MovedPermanently;
response.Status = "301 Moved Permanently";
response.RedirectLocation = normalizedUrl;
response.SuppressContent = true;
response.End();
}
}
}
And how module is register in Web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlNormalizerModule" />
<add name="UrlNormalizerModule" type="MagicByte.Web.Modules.UrlNormalizerModule, MagicByte.Web" />
</modules>
</system.webServer>
UPDATE {temporarily problem solved}
Hm... I just handled all events of HttpApplication like below
context.AuthenticateRequest +=
(sender, e) => OnAuthenticateRequest(new HttpContextWrapper(((HttpApplication) sender).Context));
I don't know why but above problem solved when i handled only few of important events such BeginRequest
. So what is really a problem because?