0

Suppose a website with a Default.aspx page.

These addresses find the Default.aspx physical file and load it:

www.mysite.com

www.mysite.com/Default.aspx

It's clear that we'll get the error 404 with this address: www.mysite.com/myvariable

Is there any way (any configuration) to make this address call the default.aspx file and ignore the /myvariable part? (or in some cases get the /myvariable value in the default.aspx.cs for example?)

As I know it could be possible in asp.net MVC, but I need to do so in asp.net web forms.

Note that the site contains other pages like info.aspx, contactus.aspx, and so on.

Thanks in advance.

2
  • 3
    You can use routing with webforms too. Commented Apr 12, 2015 at 20:26
  • Thanks alot. Yes, correct. I didn't know that's it's possible for web forms too. Commented Apr 13, 2015 at 14:26

1 Answer 1

2

To expand on what SLaks said, we use MapPageRoute.

void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("",
        "{myvariable}", "~/Default.aspx");
    routes.MapPageRoute("",
        "info", "~/Info.aspx");
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.