Solved

Asp.NET 4.0 Routing with Webforms

Posted on 2011-03-01
3
672 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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