Click here to Skip to main content
15,031,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All
I am using url rewriting.
for this i wrote following code in global file's application_start()
C#
System.Web.Routing.RouteTable.Routes.Add(
                "post_property", new System.Web.Routing.Route("{property_id}",
                new UserRouteHandler("~/SearchDetail.aspx")));


and make UserRouteHandler method in class as
C#
public UserRouteHandler(string virtualPath)
    {
        _virtualPath = virtualPath;
    }
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        if (requestContext.RouteData.Values["property_id"] != null)
        {
            var display = BuildManager.CreateInstanceFromVirtualPath(
                            _virtualPath, typeof(Page)) as IUserDisplay;
            if (display != null)
            {
                display.property_id = requestContext.RouteData.Values["property_id"] as string;
                return display;
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }
    }
     string _virtualPath;
}


and a interface
MIDL
public interface IUserDisplay : IHttpHandler
{
    string property_id { get; set; }
}


i added in web.config

XML
<httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  <add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule,                 System.Web.Routing,                 Version=3.5.0.0, Culture=neutral,                 PublicKeyToken=31bf3856ad364e35"/>
</httpModules>


and implement that interface on searchdetail.aspx
but when i redirect it it give server 404 error

It works perfectly fine on local server.
Can anyone please provide me solution for this.

Thanks in advance.
Posted

1 solution

Change the modules to
<modules runallmanagedmodulesforallrequests="true"></modules>
and see if that helps.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900