Link to home
Start Free TrialLog in
Avatar of taz8020
taz8020Flag for United Kingdom of Great Britain and Northern Ireland

asked on

How to get MapPageRoute to work with parameters VB Asp.net

Hi I am new to asp.net and i have a url which is
"~/ProductSections.aspx?ProductSections=38" but want it to look like
"/ProductSection/38/" or "/ProductSection/38.asp"

also another URL is
"~/Product.aspx?ProductRef=Mug1" but want it to look like
"/Product/Mug1/" or "/Product/Mug1.asp"


I have tried adding this to the global file but does not work
routes.MapPageRoute("Sections", "ProductSections/{ParentSectionID}", "~/ProductSections.aspx?ProductSections={ParentSectionID}", True)
        ''ProductSections.aspx?ParentSectionID=30

Any Ideas?
Avatar of lojk
lojk
Flag of United Kingdom of Great Britain and Northern Ireland image

Using MVC will give you the url format you desire (as i believe under the hood it uses the techniques you describe above) but it requires a significant shift of thinking from ASP.NET Webforms.

Here is a simple 'Getting Started' link

http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part1-cs

and here is a great example project

http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

that also talks you through using Entity Framework for the data layers as well but it is a lot to take onboard - your (lack of) experience and pre-exposure to ASP.Net in general will be more of an advantage than a disadvantage with MVC.

Microsoft consider MVC so important that they even created a new view engine language/syntax  (Razor) that effectively replaces ASP.Net Webforms although code is still written using the usual .Net languages.

It is not as simple as Webforms but it is significantly more scalable and reslient to users for example, pressing the 'back' button as you control the GET and POST verbs directly and in my experience at least, considered to be the best option for professional web site development.
Avatar of taz8020

ASKER

Hi thanks for that but the site is all done and dont want to convert it to mvc, do you know how to doit in a asp standard application?
I have never actually done it quite like this (as i went the MVC route) but where are you adding it for it not to work?

This page

http://msdn.microsoft.com/en-us/library/dd329551.aspx

says that it must be in your Application_Start. Is it?

void Application_Start(object sender, EventArgs e)
{
    RegisterRoutes(RouteTable.Routes);
}


Can you post some of your global asax or more info on why/what 'doesnt work'
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial