locked
Problem with WebResourc.axd when using Web.Routing RRS feed

  • Question

  • User-144286115 posted

    Hi All
    I am just new on Routing, Trying to use url routing in this way
    ----------------
    Global.asax
    -------------------------------------------------------------------
    routes.Add(
                "View Category",
                new Route("{CategoryName}", new CategoryRouteHandler())
                {
                    Constraints = new RouteValueDictionary { { "CategoryName", @"^[a-zA-Z'.]{1,40}$" } }
                }
            );
    Note: there are only one route
      void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
        }
    ----------------------------------------------------------------------
    --------------------------------
    App_Code/CategoryRouteHandler.cs
    ----------------------------------------------------------------------
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            string categoryName = requestContext.RouteData.Values["CategoryName"] as string;

            if (string.IsNullOrEmpty(categoryName))
                return BuildManager.CreateInstanceFromVirtualPath("~/NotFound.aspx", typeof(Page)) as Page;
    else
            {
                // Get information about this category

                MydbDataContext DataContext = new MydbDataContext();
                UserPersonalInfo userpersonalinfo = DataContext.UserPersonalInfos.Where(c => c.name == categoryName).SingleOrDefault();

                if (userpersonalinfo == null)
                    return Helpers.GetNotFoundHttpHandler();
                else
                {
                    // Store the Category object in the Items collection
                    HttpContext.Current.Items["Category"] = userpersonalinfo;

                    return BuildManager.CreateInstanceFromVirtualPath("~/CategoryProducts.aspx", typeof(Page)) as Page;
                }
            }
        }
    -----------------------------------------------------------------------------------

    It works fine when I invoke category stored in our database,
    But CategoryRouteHandler.cs caught instanc of Resource.axd!
    Other client side content not loded properly Like css and javascript
    Firefox shows it syntax error Like:
    Error: syntax error
    Source File: http://localhost:1098/MyNewWebsite/Login.aspx
    Line: 2
    Source Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Note: I am using Sqlprovider profile service
    I am not understanding what to do with Problem
    help please!
    Regard
    S Samual


    Friday, December 25, 2009 1:21 AM

Answers

All replies