Click here to Skip to main content
16,015,583 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
suppose i want that routing should ignore *.js files *.css and *.png etc

i search google and found solution. which i implement in my page but still js files are not downloading.

here is my code

C#
void Application_Start(object sender, EventArgs e)
    {
        RouteTable.Routes.Ignore("images/{*pathInfo}");
        RouteTable.Routes.Ignore("Scripts/{*pathInfo}");
        RouteTable.Routes.Ignore("Styles/{*pathInfo}");


        RouteTable.Routes.MapPageRoute("Source", "UrlRewrite/Approach1/Source/{ID}/{Title}", "~/UrlRewrite/Approach1/Source.aspx");
        RouteTable.Routes.MapPageRoute("Source2", "UrlRewrite/Approach1/Source/{Question}/{ID}/{Title}/{Page}", "~/UrlRewrite/Approach1/Source.aspx");
        RouteTable.Routes.MapPageRoute("Source1", "Feedback/{ID}/{Title}", "~/Feedback.aspx");
        //RouteTable.Routes.MapPageRoute("Source1", "Source.aspx{?}{ID}{&}{Title}", "~/UrlRewrite/Approach1/Source.aspx");
        RouteTable.Routes.MapPageRoute("product", "Data/product.aspx/{*ID}", "~/UrlRewrite/Approach1/Source.aspx");  // url mapping with * routing

    }


so tell me my code is ok for Ignore few files type. why my js is not downloading. my css file are in Styles folder, my js files are in Script folder etc. the Script & Styles folder in root. please guide me. thanks
Posted

1 solution

Hi, have you tried on of these

C#
'RouteTable.Routes.RouteExistingFiles = False
       'routeCollection.Ignore("css/{*pathInfo}")
       'routeCollection.Ignore("{resource}.css/{*pathInfo}")
       routeCollection.Ignore("{resource}.axd/{*pathInfo}")
       'routeCollection.Ignore("{resource}.jpg/{*pathInfo}")
       'routeCollection.Ignore("{*allaspx}", New With {.allaspx = ".*\.aspx(/.*)?"})
       'routeCollection.Ignore("{file}.js")
       'routeCollection.Ignore("{file}.css")
       'routeCollection.Ignore("{file}.png")


       'routeCollection.Ignore("{*alljs}", New With {.alljs = ".*\.js(/.*)?"})

       'routeCollection.Ignore("{folder}/{*pathInfo}", New With {.folder = "css"})
 
Share this answer
 

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



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