Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Asp.NET 4.0 Routing with Webforms

Posted on 2011-03-01
3
Medium Priority
?
675 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 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