简体   繁体   中英

ASP.NET WebForms - routing gives 'page not found error '

I am using asp.net routing and getting a 404 error.

If I do not use an id value then I can see page.

But I want to pass id data with route and getting 404 Page Not Found error.

Not sure why we see error when we want to use parameters.

With Parameters (404 File or Directory not found error)

 routes.MapPageRoute( "Product", "product/{id}", "~/Pages/Product.aspx" );

Without Parameters (Page Works)

 routes.MapPageRoute( "Product", "product", "~/Pages/Product.aspx" );

UPDATED NOTE: I have tested all routes if i add product/{id}, contact/{id} or etc. It causes all the same 404 error.

URL: test.com/product > WORKS
test.com/product/{id} > NOT FOUND

try this with * query values

routes.MapPageRoute(
       "Product",
        "product/{Id}/{*queryvalues}",
        "~/Pages/Product.aspx"
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM