Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-03-23
4
Medium Priority
?
1,480 Views
Last Modified: 2012-04-06
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?
0
Comment
Question by:taz8020
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:lojk
ID: 37757419
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.
0
 
LVL 3

Author Comment

by:taz8020
ID: 37757518
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?
0
 
LVL 9

Expert Comment

by:lojk
ID: 37757567
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'
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 37758116
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question