Solved

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

Posted on 2012-03-23
4
1,428 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 500 total points
ID: 37758116
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

710 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