Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 31, 2012 04:19 PM by tarunSaini
Jul 29, 2012 12:33 PM|LINK
I have implemented routing on my asp.net web appilcation, so that user can call something like:
This link opens Register.aspx page. At the moment people can also open this page using:
Is there a way I can stop people being able to call the .aspx directly? e.g. authorise people who types in www.mysite.com.au/registermember, and redirect people to homepage when people type in
thanks in advance
Jul 29, 2012 01:10 PM|LINK
Your question is not clear "Is there a way I can stop people being able to call the .aspx directly". when user comes to Register page automatically validate and redirect to home page, is that correct or please give more details.
Jul 29, 2012 01:21 PM|LINK
You can write a rule for it or can write Response.RedirectToRoute("registermember") in your code behind.
Jul 29, 2012 02:41 PM|LINK
hi venkat, thanks for your quick response. Basically I don't want people to be able to open the page by calling
www.mysite.com/register.aspx. here is the rules I expect to be able to apply:
* if user types in www.mysite.com/registermember, --> open the page
* if user types in www.mysite.com/register.aspx --> reject page request and maybe redirect user to a "page not found" page
Already implemented rule No.1, but need to learn how to implement No.2 role.
Jul 29, 2012 03:23 PM|LINK
When a page is requested, a Request object is created. This Request object contains all the vital information from where it is being called. For your current situation Request.UrlReferrer properties does the job. It contains information from which url it
is being called. You can implement this in to your register.aspx page.
for e.g. if you are calling register.aspx page from www.mysite.com/registerfirstpage.aspx, the register.aspx "Request.UrlReferrer" will contain url of www.mysite.com/registerfirstpage.aspx.
If you still have any query please let me know.
Jul 30, 2012 02:39 PM|LINK
thanks for your help, but I am not trying to call one page from another.
www.mysite.com/register.aspx is the actuaal page,
www.mysite.com/registermember is the routing which opens register.aspx page.
still stuck :(
Jul 31, 2012 04:54 AM|LINK
it does not matter either you are calling from one page to another, it works even the link is coming from different site.
Jul 31, 2012 05:10 AM|LINK
you misunderstood my issue.
I want to stop people being able to call .aspx page directly. i.e.
If people type in www.mysite.com/register.aspx they will not be able to get onto the page, instead they can only type in the routed URL, which is
thanks for trying to help anyway, very much appreciated
Jul 31, 2012 10:43 AM|LINK
Did you try using Respose.RedirectToRoute("registermembership") in the code behind of register.aspx page? It will automatically redirect user to the required URL.
Jul 31, 2012 03:02 PM|LINK
thanks for your advise, in order to do Response.RedirectToRoute("regisermembership") in Page_Load method, I need to know if user is calling the register.aspx page directly. Otherwise the page will run into a deadloop withthis line...
any idea how to find out whether user is calling the regiser.aspx page directly?