Mert
Mert

Reputation: 99

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 iddata 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

Upvotes: 0

Views: 337

Answers (1)

Brave Soul
Brave Soul

Reputation: 3620

try this with * query values

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

Upvotes: 1

Related Questions