Solved

Asp.NET 4.0 Routing with Webforms

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

Accepted Solution

by:
paulmacd 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

19 Experts available now in Live!

Get 1:1 Help Now