Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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