Solved

Asp.NET 4.0 Routing with Webforms

Posted on 2011-03-01
3
669 Views
Last Modified: 2012-05-11
Hello,

We are using routing with webforms via asp.net 4.0 and the routing is working great.  Our question though is we can't find anywhere on the web where it addresses the issue of accessing our pages directly still using .aspx

For example, we have a route setup (http://www.xyz.com/account) for the physical page (account.aspx)  The problem is I can go on our site and see the account page using the url http://www.xyz.com/account.aspx

The other issue is that the route contains some other parameters as part of the route itself.  For example..... /account/profile which tells which tab on the account page to display.  Accessing this page with just account.aspx breaks it.

Can we easily deny access to the actual .aspx extensions?  

Thanks. Steve
0
Comment
Question by:kruegerste
3 Comments
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 35011172
In the Page.Load you could parse the URL for ".aspx" and redirect to the same URL without the extension.
0
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 35011188
Look into URL rewriting: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

If you read the info I link to it should give you everything you need and then some.
0
 
LVL 4

Author Comment

by:kruegerste
ID: 35011356
@paulmacd: that is not a bad idea, check for .aspx in the url and if it exists, then redirect to the routed version. and if there are parameters in the route that are missing cause using .aspx, then i guess we could either select a default route version of that page.  or even better, if they use the .aspx, then redirect all these to the pagenotfound.aspx route and not even try to specify correct route since they shouldn't be using the .aspx version.  cool

@rawinnlnx9:  url rewriting is not desirable, it is what has to be used in 3.5 and earlier.  Web routing for 4.0 is a much better solutions for many reasons.  We can't go backwards for this one minor issue.  Thanks though for reply.  

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

772 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