Solved

Asp.NET 4.0 Routing with Webforms

Posted on 2011-03-01
3
670 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

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

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…
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 …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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