473,654 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I deny all users directly access image files from images folder?

ABC


How can I deny all users directly access image files from images folder?


Nov 19 '05 #1
7 3865
You cannot. At least you cannot by using a standard mechanism.

If you want to do such a thing, you have to develop a component that
displays the images by requesting them with an identity that has access
to the image folder and then restrict access to all users. Eitherway,
it's not a configuration or trivial task.

A good idea would be to scramble the names of the images so the users
cannot guess the imagefilenames.

Nov 19 '05 #2
AF
> How can I deny all users directly access image files from images folder?
Into the 'application settings' (IIS manager properties) you may add the picture
extensions to the list of files parsed by the Dotnet engine..

Example:
add the executable 'C:\WINNT\Micro soft.NET\Framew ork\v1.1.4322\a spnet_isapi.dll '
to the extension '.jpg'
verbs: 'GET'

Then, you may code any business rule into your global.asax::Ap plication_Begin Request
method:

string extension = MyUtils.GetExte nsion(Request.U rl.toString());
string referrer = Request.UrlRefe rrer;
if(extension.Eq uals("jpg") && (!MyUtils.IsRef errerValid(refe rrer))
{
Response.Write( "direct access denied.");
Response.End();
}
Antonio Fontes
http://www.futureblogs.net/antonio

Nov 19 '05 #3
AF
I forgot to say that this method also can be a good practice to
manage a deep bandwidth usage control for example when
a certain amount per client is allowed:

global.asax::Ap plication_Begin Request()
{
// example url: http://mydomain.com/uploads/1289473/pics/mypic.jpg
string url = Request.Url.ToS tring();
string filePath = Server.MapPath( MyUtils.ParseUr lPath(url));
long clientRef = MyUtils.ParseCl ientRef(url);

// get file length
int fileSize = new FileInfo(filePa th).Length;

// add to bandwith usage
CustomerUtils.I ncrementBandwit thUsage(clientR ef, fileSize);
}

Antonio
http://www.futureblogs.net/antonio
Nov 19 '05 #4
And how he is going to display this images to his site ? I thought that
he want to prohibit DIRECT access to the img folder

Nov 19 '05 #5
AF
> And how he is going to display this images to his site ? I thought that
he want to prohibit DIRECT access to the img folder


The beginrequest event is triggered before delivering the resource.
If you read the first code example I've posted, there's a check on
the referrer validity: MyUtils.IsRefer rerValid(referr er).

If the referrer is valid, then there's nothing to do... just let the request
processing go on.

Antonio Fontes
http://www.futureblogs.net/antonio
Nov 19 '05 #6
re:
MyUtils.IsRefer rerValid(referr er)


Is that a class you wrote, Antonio ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"AF" <nX************ @nXxtg.XnetX> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
And how he is going to display this images to his site ? I thought that
he want to prohibit DIRECT access to the img folder


The beginrequest event is triggered before delivering the resource.
If you read the first code example I've posted, there's a check on
the referrer validity: MyUtils.IsRefer rerValid(referr er).

If the referrer is valid, then there's nothing to do... just let the request
processing go on.

Antonio Fontes
http://www.futureblogs.net/antonio

Nov 19 '05 #7
AF
> > MyUtils.IsRefer rerValid(referr er)
Is that a class you wrote, Antonio ?


This is what I would write. I haven't coded it, it was just needed
to give some example to my answer.
But that could look like:
---------------------------------------------------
IsReferrerValid (string aReferrer)
{
HttpContext ctx = HttpContext.Cur rent;
if(ctx == null)
return false;

string validDomain = MyUtils.GetSett ingsFromWebConf ig("mydomain") ;
string currentDomain = ctx.Request.Url .Host;
if(currentDomai n.Equals(validD omain))
return true;
else
return false;
}
---------------------------------------------------

The valid domains list could be a single item in web.config, or an
arraylist retrieved from a database or whatsoever.
Antonio Fontes
http://www.futureblogs.net/antonio
Nov 19 '05 #8

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

Similar topics

2
1206
by: spike | last post by:
I tried to upload a .htaccess-file to the directory that i wanted to protect. This is what I wrote in it: ------------------------------------------------ <Limit GET> order deny,allow deny from all allow from mydomain.com </Limit>
20
2384
by: Greg | last post by:
I'm fairly new to access (using 2002) and am setting up a DB for work. along with each record the user also needs to make a flow diagram (previously, these reports were composed in word and they used the autoshapes to create this diagram). I was wondering what the best way to incorporate this into the DB. I have read about how saving them as pictures in the DB bloats the size, which is unacceptable, but it needs to be easy to do (not...
9
3421
by: Matt | last post by:
Hello, I'm working on a portal based on IBuySpy, where the main page is desktopdefault.aspx and all content is stored in www.domain.com/content/html/nnn or www.domain.com/content/images/nnn and injected in the desktopdefault.aspx page. How can I prevent users doing www.domain.com/content/images/test.jpg and getting the image (or the html file, or whatever inside the
13
2345
by: Neo Geshel | last post by:
I have examined about 80+ different upload scripts on the 'net, both in VB and C#, and none seem to do what I need them to do. Perhaps someone here can point me somewhere that Google hasn't reached yet (I have gone all the way to page 50 on Google's results!!). Here are my requirements: • I have a DataGrid. Everything will be done from here. Everything. No exceptions. Everything will also be done in VB, without any code-behind to...
5
1586
by: jcrouse | last post by:
I saw an article, once, on how to package image file in the installer so they are not accessible to the end user. I want to say hidden, but I don't just mean the file attribute of the image file. Does anyone know of the article I'm speaking of or a link on how to embed (another poor choice of words) the image files in the executable? Thanks, John
2
5225
by: Tim::.. | last post by:
Hi can someone please tell me why this web.config file doesn't deny access to all for the folder it is in??? I have the web.config file in a folder called contents but for some reason I can still access this folder. I am using Forms authentification and I just can't get it to work! PLEASE help... Thanks
1
2483
by: Sunshine192 | last post by:
Hi, I'm still kinda new to PHP so I could do with some advice. I'm using the code below to select and show a random image from a folder of images. rotate.php <?php // Make this the relative path to the images, like "../img" or "random/images/". // If the images are in the same directory, leave it blank. $folder = ''; // Space seperated list of extensions, you probably won't have to change this.
7
8472
by: Jurjen de Groot | last post by:
I'm developping a web-app using VS2008 (Pro edition) on a Vista Ultimate machine .. For some reason images aren't shown, the only thing shown is the little square with the circel, triangle and square in it. Even if I set the ImageURL property in my Page_Load and set it to the absolute path of the image, it doesn't show. I have also tried using '~/Images/58.jpg' '/Images/58.jpg' 'Images/58.jpg' but still the same result.
3
3274
by: Rishabh Indianic | last post by:
Hi, I am used VS 2005 with c# for developing window mobile application. When i create a cab file i add Primary Output and Content files from project. The content file contain image folder. When I install application in device using cab file it create a folder which contain the images that i have used in project By Programmatically by accessing path " (//Program FIles//Images//Image.jpg1) " it work well. problem is that this content file is...
0
8706
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
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 we have to send another system
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.