Facing some problem when I call begin_request of httpModule

Discussion in 'Site Programming, Development and Design' started by akumar, Dec 2, 2010.

  1. I am facing some problem when I call begin_request of httpModule. This begin_request is working/calling locally but when I upload it on production server than it is not calling . Please let me know the solution. Its very urgent for me.

    My code is ---

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Web;

    using System.Configuration;

    using System.Xml;

    using System.Text.RegularExpressions;

    using System.Web.UI;

    using System.IO;

    using System.Collections.Specialized;

    /// <summary>
    /// Summary description for RewriteModule
    /// </summary>
    public class RewriteModule : IHttpModule
    {

    public void Init(HttpApplication context)
    {
    // it is necessary to
    context.BeginRequest += new EventHandler(
    RewriteModule_BeginRequest);


    }
    void RewriteModule_BeginRequest(object sender, EventArgs e)
    {

    string rawurl = HttpContext.Current.Request.Url.ToString();
    string[] arr = rawurl.Split('/');
    for (int i = 0; i < arr.Length; i++)
    {
    if (arr == "Pages")
    {
    i++;
    if (arr == "default.aspx")
    {
    HttpContext.Current.Response.Redirect("../default.aspx");
    break;
    }
    if (arr == "Admin.aspx")
    {
    HttpContext.Current.Response.Redirect("../Admin.aspx", false);
    break;
    }
    if (arr == "UserAccount.aspx")
    {
    HttpContext.Current.Response.Redirect("../UserAccount.aspx", false);
    break;
    }
    if (arr == "NewSearch.aspx")
    {
    HttpContext.Current.Response.Redirect("../NewSearch.aspx", false);
    break;
    }
    if (arr == "NewAddHike.aspx")
    {
    HttpContext.Current.Response.Redirect("../NewAddHike.aspx", false);
    break;
    }
    if (arr == "SafetyInfo.aspx")
    {
    HttpContext.Current.Response.Redirect("../SafetyInfo.aspx", false);
    break;
    }
    if (arr == "Contact.aspx")
    {
    HttpContext.Current.Response.Redirect("../Contact.aspx", false);
    break;
    }

    //else
    //{
    // HttpContext.Current.Response.Redirect(rawurl);
    // break;
    //}

    }
    }

    }


    public RewriteModule()
    {

    //TODO: Add constructor logic here

    }
    public void Dispose() { }
    }


    and I wrote some line in Web.config file

    <httpModules>

    <add name="RewriteModule" type="RewriteModule"/>

    </httpModules>




    Plsssssssssss help me
     
  2. Ray

    Ray

    Can you give us a copy on what you wrote on the web.config file for the URL Rewrite rule?
     

Share This Page