Solved

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

Posted on 2012-03-23
4
1,355 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now