473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Usage of "Request.UrlReferrer"

I've got \\root\folder\Page2.aspx that I want to controll
access to, by establishing a rule that says "previous URL
must be '\\root\folder\Page1.aspx' (which did password
validation). The code snippet below does 1) allow valid
Page_Load if referring URL was 'Page1', and 2) disallows
Page_Load if the *initial* access attempt was PRIOR to
any valid load of 'Page2'...
<code>
// In Page_Load...
// check the prior URL and make sure our access
// came from the correct first page.
//
bool bBadRef = false;
System.Uri referrer = Request.UrlReferrer;
if (referrer == null)
bBadRef = true;
else
{
string csRef = "NONE";
string csRefPath = "NONE";
try
{
csRef = referrer.AbsoluteUri;
csRef = csRef.ToLower();
csRefPath = csRef.Substring(csRef.IndexOf
("folder"));
}
catch (Exception refxc)
{
throw new Exception(csRef);
}
if (csRefPath != "folder/Page1.aspx")
{
bBadRef = true;
}
}
if (bBadRef)
{
this.Response.Close();
return;
}
</code>

PROBLEM: If *after* I accomplish a valid access to Page2
(i.e. via Page1), then browse to a completely different
unrelated web page, I am then able to *directly* plug the
Page2 URL into my browser Address field and validation
does NOT fail! Could this be due to some kind of
caching effect that I'm not taking into account?
I'm rather new to aspx, so consider this a 'newbie'
question! Thanks!
Jim
Nov 18 '05 #1
1 3174
just use forms control and get the redir to login page on un authorised
access....

you might find the following links useful...

How To: Create GenericPrincipal Objects with Forms Authentication (.NET
Framework Security)
Create and handle GenericPrincipal and FormsIdentity objects when using
Forms authentication. (9 printed pages)
http://msdn.microsoft.com/library/en...secnetht04.asp
Forms Authentication Provider (.NET Framework Developer's Guide)
Forms authentication generally refers to a system in which unauthenticated
requests are redirected to an HTML form, using HTTP client-side redirection.
http://msdn.microsoft.com/library/en...onprovider.asp
Simple Forms Authentication (.NET Framework Developer's Guide)
This example presents the simplest possible implementation of ASP.NET forms
authentication. It is intended to illustrate the basic fundamentals of how
to create an ASP.NET application that uses forms authentication.
http://msdn.microsoft.com/library/en...entication.asp
Simple Forms Authentication (.NET Framework Developer's Guide)
This example presents the simplest possible implementation of ASP.NET forms
authentication. It is intended to illustrate the basic fundamentals of how
to create an ASP.NET application that uses forms authentication.
http://msdn.microsoft.com/netframewo...entication.asp
Simple Forms Authentication (.NET Framework Developer's Guide)
This example presents the simplest possible implementation of ASP.NET forms
authentication. It is intended to illustrate the basic fundamentals of how
to create an ASP.NET application that uses forms authentication.
http://msdn.microsoft.com/vcsharp/us...entication.asp
Simple Forms Authentication (.NET Framework Developer's Guide)
This example presents the simplest possible implementation of ASP.NET forms
authentication. It is intended to illustrate the basic fundamentals of how
to create an ASP.NET application that uses forms authentication.
http://msdn.microsoft.com/webservice...entication.asp
How To: Use Forms Authentication with SQL Server 2000 (.NET Framework
Security)
Implement Forms authentication against a SQL Server credential store. It
also shows you how to store password digests in the database. (12 printed
pages)
http://msdn.microsoft.com/library/en...SecNetHT03.asp
How To: Use Forms Authentication with Active Directory (.NET Framework
Security)
Implement Forms authentication against an Active Directory credential store.
(11 printed pages)
http://msdn.microsoft.com/library/en...secnetht02.asp
Forms Authentication Across Applications (.NET Framework Developer's Guide)
ASP.NET supports forms authentication in a distributed environment, either
across applications on a single server or in a Web farm.
http://msdn.microsoft.com/library/en...plications.asp

Regards,

HD

<an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I've got \\root\folder\Page2.aspx that I want to controll
access to, by establishing a rule that says "previous URL
must be '\\root\folder\Page1.aspx' (which did password
validation). The code snippet below does 1) allow valid
Page_Load if referring URL was 'Page1', and 2) disallows
Page_Load if the *initial* access attempt was PRIOR to
any valid load of 'Page2'...
<code>
// In Page_Load...
// check the prior URL and make sure our access
// came from the correct first page.
//
bool bBadRef = false;
System.Uri referrer = Request.UrlReferrer;
if (referrer == null)
bBadRef = true;
else
{
string csRef = "NONE";
string csRefPath = "NONE";
try
{
csRef = referrer.AbsoluteUri;
csRef = csRef.ToLower();
csRefPath = csRef.Substring(csRef.IndexOf
("folder"));
}
catch (Exception refxc)
{
throw new Exception(csRef);
}
if (csRefPath != "folder/Page1.aspx")
{
bBadRef = true;
}
}
if (bBadRef)
{
this.Response.Close();
return;
}
</code>

PROBLEM: If *after* I accomplish a valid access to Page2
(i.e. via Page1), then browse to a completely different
unrelated web page, I am then able to *directly* plug the
Page2 URL into my browser Address field and validation
does NOT fail! Could this be due to some kind of
caching effect that I'm not taking into account?
I'm rather new to aspx, so consider this a 'newbie'
question! Thanks!
Jim

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sam Sungshik Kong | last post by:
Hello! I use Python for ASP programming. I found something weird. Response.Write(Request("something")) It draws "None" when there's no value for something. Actually I expect "" instead of...
1
by: Matt | last post by:
If we use GET protocol, we can use either Request("controlname") or Request.QueryString("controlname") to get the data entered by the user. But if we use POST protocol, we MUST use...
32
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open...
0
by: Ian Staines | last post by:
In asp the following code: Request.Servervarables("AUTH_USER") will return the header variable AUTH_USER In .NET the code Request.Servervariables("AUTH_USER") returns the server variable...
4
by: Ben Amada | last post by:
Hello! There are a couple of visitors (out of dozens) to this web page who are causing the following error to occur: "Object reference not set to an instance of an object." I'm actually...
0
by: . | last post by:
http://daviderognoni.blogspot.com?locawapp - MAIN NEWS =========== * add thread * add "Request" object * new "locawapp_main" function * fixed files.py
1
by: Christian Blackburn | last post by:
Hi Gang, I'm using the following code to generate a complete URL: Session("Destination") = Request.ServerVariables("Path_Info") & "?" & Request.ServerVariables("QUERY_STRING") However that...
7
by: vvkl | last post by:
I have readed a example code from MSDN about FormsAuthenticationTicket calss, but there's a line I can't understand : 'strRedirect = Request;' What's the mean in which square brackets? Thank...
7
by: sami | last post by:
Hi I am trying to write a facebook application in python - I have been programming simple desktop applications till now and am not really familiar with web apps Pyfacebook is the wrapper for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.