473,513 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deny downloading of resources by checking if the request is from a page component or

1 New Member
I am trying to restrict direct access and downloading of files from my resources folder. I have implemented this in my global.asax:
Expand|Select|Wrap|Line Numbers
  1. void Application_BeginRequest(object sender, EventArgs e)
  2. {
  3.     HttpApplication application = (HttpApplication)sender;
  4.     HttpRequest request = application.Context.Request;
  5.  
  6.     if (request.Url.ToString().Contains(@"/resources/"))
  7.     {
  8.         Server.ClearError();
  9.         Response.Clear();
  10.         Response.Redirect(@"http://mysitename.com/download_restriction.aspx");
  11.     }
  12. }
It works however, it restricts my pages from using the resources as well... Can I somehow check if the request is being done from one of my pages?
Aug 15 '13 #1
2 1374
Frinavale
9,735 Recognized Expert Moderator Expert
Have you considered using proper Authentication and Authorization like forms authentication?

-Frinny
Aug 20 '13 #2
univercel
11 New Member
You may check referral URL for this HTTP request.
Aug 21 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1547
by: cliff | last post by:
I am in the process of developing an application and would like to hide the query strings in the URLs. I want to POST data to a page then validate the data. If there is an error I have to send data...
6
7346
by: mt404 | last post by:
Hi, I was wondering if someone might be able to provide some guidance on how I could make an http request from a C# library. Basically I have a library which accepts a couple of arguments that...
3
2412
by: Peter Theill | last post by:
Hi, I'm trying to include the content of a request into an Xml document: if (System.Web.HttpContext.Current.Session != null) { XmlDocument d = new XmlDocument(); d.Load(new...
2
2232
by: mtanner | last post by:
I have a aspx page that is not secured via SSL, and the page must remain unencrypted. However, the page includes a web user control (ascx) that contains textboxes and submit button for login. The...
3
7696
by: Sydney | last post by:
Hi, I am trying to construct a WSE 2.0 security SOAP request in VBScript on an HTML page to send off to a webservice. I think I've almost got it but I'm having an issue generating the nonce...
7
2519
by: SevDer | last post by:
Hi I have a class library that needs to download the HTML in a specific page of ours with provided querystring. When I open this URL with any browser, it loads fine. When I do WebRequest from Web...
3
5356
by: Laith Zraikat | last post by:
I need to set the page title for a content page in a master page, and do that using local reources so that I can have my page title in different languages. I can do that easily using global...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
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
7379
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
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
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
7521
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...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.