To Get Direct File Access To Files Within The Web Directories From .NET Application?

Jan 10, 2011

My ASP.NET application logs transactions (both inside AND outside of databases), and therefore needs read/write access to text files within various directories within the root of the website - in ADDITION to the normal database access.

In this scenario, how can I safely allow my ASP.NET application to write data to the web folders? I have a thread-safe DLL that performs the actual work, so I don't believe I need to worry about multiple sessions writing to the log files at the exact same time - assuming my DLL will only be running in a single instance/process that will be shared between numerous ASP.NET instances/processes/threads.

But I'm more concerned about file access permissions. I've heard that ASP.NET applications generally aren't allowed access to the webserver's local file system, and that this may even restrict my DLL from getting the correct file access. Can I grant my application file-access to the web-driectories?

View 1 Replies


Similar Messages:

Security :: Disallow Direct Access To Files?

Aug 19, 2010

Here is my dilema, on my site i have a WordPress Audio player (http://wpaudioplayer.com/standalone) that plays my mp3's.

It loads the Mp3's in by javascript...example below:

AudioPlayer.embed("audioplayer_7", { soundFile: "/Files/Music/[name of file].mp3" });

This file name is clearly visible in the browser source. Not a problem, however this means that any user can legitimately browse to the file directly and download it.

Now i still need the mp3 player (which is flash) to have access to the file but if a user was to try accessing the file directly, they would not be allowed access to it.

I am not sure how to go about this, i am circling the idea of a httphandler but not sure if this is sufficiant to stop the direct access to the file.

View 2 Replies

Web Forms :: How To Read Files From Directories Outside The Application

Feb 4, 2010

i have different number of directories containing files and i need to have hyperlinks so that user can download files to their ends. problem is that these directories are outside the application directory. how to map these files paths and name so that when user right click and save it on his machine or just clicking it..... what i have to do beside setting permission to reading those directories..

View 7 Replies

How To Get Files In Vb.net In All Directories

Oct 25, 2010

This is in class file
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Collections.Generic
Public Class FileSrch
'' File Search Options
Public Enum FileSearchOptions
YearFirst
MonthFirst
DateinExtension
NormalFiles
End Enum
Public Shared Function GetSearchcriteria(ByVal DatetoSearchwith As Date, ByVal Filename As String, ByVal FileExtension As String, ByVal SearchOptions As FileSearchOptions)
Select Case SearchOptions
Case FileSearchOptions.YearFirst
Return String.Format("{0}_{1:yyyyMMdd}{2}", Filename, DatetoSearchwith, FileExtension)
Exit Select
Case FileSearchOptions.MonthFirst
Return String.Format("{0}_{1:yyyyMMdd}{2}", Filename, DatetoSearchwith, FileExtension)
Exit Select
Case FileSearchOptions.NormalFiles
Return String.Format(Filename + FileExtension)
Case FileSearchOptions.DateinExtension
Dim ExtensionFormat As String = (Convert.ToInt32(DatetoSearchwith.ToString("mm")).ToString() & DatetoSearchwith.ToString("dd"))
'' Month in Double Digit
If DatetoSearchwith.Month > 9 Then
ExtensionFormat = (DatetoSearchwith.ToString("mmm")(0) & DatetoSearchwith.ToString("dd"))
End If
Return String.Format("{0}.{1}", Filename, ExtensionFormat)
Case Else
Return String.Format("{0}.{1}", Filename, FileExtension)
End Select
End Function
Public Shared Function GetFiles(ByVal RootDirectory As DirectoryInfo, ByVal Filename As String, ByVal FileExtension As String, ByVal DatetoSearchwith As Date) As List(Of FileInfo)
Dim FiFiles As New List(Of FileInfo)
For Each DateOption As FileSrch.FileSearchOptions In [Enum].GetValues(GetType(FileSrch.FileSearchOptions))
FiFiles.AddRange(RootDirectory.GetFiles(FileSrch.GetSearchcriteria(DatetoSearchwith, Filename, FileExtension, DateOption), SearchOption.AllDirectories))
Next
Return FiFiles
End Function
End Class
This in Button Click
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FileName As String
' Dim fileName As String = txtextension.Text.Trim().Substring(0, txtextension.Text.Trim().IndexOf("."))
If txtextension.Text.Contains("_") Then
FileName = txtextension.Text.Trim().Substring(0, txtextension.Text.Trim().IndexOf("_"))
Else
FileName = txtextension.Text.Trim().Substring(0, txtextension.Text.Trim().IndexOf("."))
End If
Dim extensionToSearch As String = Path.GetExtension(txtextension.Text)
'Dim Directory As String = Path.GetDirectoryName(txtpath.Text.Trim())
Dim Directory As New DirectoryInfo(txtpath.Text.Trim())
'Dim filess As String() = Directory.GetFiles(txtpath.Text, txtextension.Text, SearchOption.AllDirectories)
'For Each fiFile As String In filess
' Response.Write(fiFile & "</br>")
'Next
Dim SearchedFiles As List(Of FileInfo) = FileSrch.GetFiles(Directory, fileName, extensionToSearch, Now.Date())
'Dim searchedFiles As List(Of FileInfo) = GlobalStuff.GetFiles(directoryToSearch, "whateverfilename", extensionToSearch, DateTime.Now)
If (SearchedFiles IsNot Nothing AndAlso SearchedFiles.Count > 0) Then
For Each fi As FileInfo In SearchedFiles
Response.Write(fi.Name & "</br>")
Next
Else
Response.Write("No files found")
End If
End Sub

Now,we need to address the following things in that to complete req, 1) If I enter filename_mmddyyyy.txt it should fetch only files having current date in their name in mmddyyyy format.For eg. If I give test_mmddyyyy.txt in txtextension it should return only files with test_10222010.txt and not thee ones with yyyymmdd and all...Right now I am getting all the files created in the current date including the one with ordinary test.txt and also test_20101022.txt .......And the third thing filename.mdd everything is getting passed correctly but it is not fetching the file ..Again test,test_20101022.txt everything comes.It shouldn't be like that it should only fetch files with .mdd (current date)....

In my above code i have two text boxes one for file path and other one for getting extension and also for gettting file names with diff search criteria.....What i do is i should implement file search which is like as mentioned below -

1) it should search for all files if i enter *.*,only jpg if *.jpg, and files like nks.txt if i enter ?

2) if i enter the filename alone without extn it should return me filenames that exist without extension in directories. 3) the final thing is the date in filename where my file will be like filename_mmddyyyy.txt or filename_yyyymmdd.txt or filename.mdd.In first case it should return only files with current date in mmddyyyy format and txt extn....like taht....last case is mdd in extn...

where if i enter filename.123,it sould get me files with jan 23(23 currnt date) and for months greater than 9 it is N for nov ,D for dec and so on.But in m,ytext box i will enter only file.mdd only .and also filename_mmddyyyy.jpg like that....

View 2 Replies

Web Forms :: : .NET Application Not Accessible And Access Denied For Some Application Files?

May 12, 2010

We have an ASP.NET 3.5 Web application in which we have faced the below issue:

The application is working fine but suddently at one point application URL prompts for the authentication. When we (the support team) checked the server, we were able to identify that the access was denied for some of the main files (like web.config, default page). When we enabled the access the application started working fine.

View 2 Replies

MVC Routing For Files With Muliple Sub-directories?

Aug 18, 2010

I need to setup a file handler to route with multiple sub directories something like tihs;

http://localhost/images/7/99/786936215595.jpg

I tried putting this in the global.asax file;

routes.Add(
"ImageRoute",
new Route("covers/{filepath}/{filename}",
new ImageRouteHandler()));

I am using the ImageHandler found in this Question, which works great if you have a single sub-directory (ie '/images/15/786936215595.jpg') but fails when you have multiple directories.

I tried setting up a wildcard and that didnt work (ie 'new Route("covers/{filepath}/*/{filename}"')

This is serving images from a large NAS (think something like 3 million images) so its not like I can just move files around.

View 2 Replies

C# - Loop Through Directories And Search For .JPG Files?

Oct 15, 2010

I have this code and I'm getting an IOException and can't figure out what the problem is. I'm trying to loop through the subdirectories in a directory and list all of the .JPG files.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["AllEmpsLoadPath"] = "\\intranet.org\Photo Album\Employees";
}

[Code]....

View 2 Replies

How To Prevent Direct Linking To A Few Pdf Files

Sep 22, 2010

I'm working on a website where I need to prevent the direct linking to a few pdf files. I'm using ASP.net 2.0. Is there an easy way in code to do this? or some simple IIS setting?

Right now i'm just using a standard anchor tag to link to the files. i can validate the user on the page containing the anchor tag but that still doesn't stop the user from nabbing the url and passing it on to someone else.

View 4 Replies

How To Add IIS Virtual Directories And Arbitrary Files In TFS Solution

Feb 11, 2010

We have a web portal product from which we customize portals from customers. We use the precompiled web app and create a virtual directory (vd) where the customization resides. In addition to this we do some changes web.config in the web app folder. We would obviously like to keep these customizations under TFS source control.

When I try to add the precompiled web app (which I don't want to add to source control), a warning tells me that the vds cannot be added. If I only add the folder that is referenced to by the vd, I lose the references to assemblies in the precompiled web app.

My questions are:

How do I structure a solution for adding IIS (sub application level) virtual directories and still retain the references to assemblies? Is it possible to add other directories/files from the web application level (like App_Theme, web.config etc.) to the solution?

Since we already use Visual Source Safe, we have established a tree structure for each customization project:

Project Root
|
|-Custom Sql
|
|-Custom Portal Files (which is added as a virtual directory)
|
|-Other Customizations

I could probably do a lot of this manually through the source control explorer, but I'd like to have everything done through a solution.

I've followed the instructions using this article: [URL], but this doesn't address the exact problem that I have. Oh, and we are currently using Visual Source Safe for portal customizaton, but are eager to make the move to TFS.

View 2 Replies

Moving Directories/files From The Server To Another Network Location?

Oct 5, 2010

In my asp.net wep application i would like to move the folders from the server to a network location so that the server doesnt get filled up.

i was able to move the files within the same drive but not to other network locations .

View 11 Replies

Setup IIS 6 To Only Server Static Files From Virtual Directories?

Jun 21, 2010

We're having the same setup and receiving the same problem as:

[URL]

Setup
Server 2003 32bit, IIS 6
ASP.NET wild card mapping

A virtual directory mapped to an UNC share serving static images for a CMS in a load balancing environment

My question if it's possible to turn off asp.net from virtual and only serve static files e.g. images in the virtual directory, to avoid the problem with too many open connections?

If it's not possible I'll guess I have to implement a solution like [URL] to server the files from a local disc.

I found a possible solution at [URL] that removes the wild card mapping and makes it possible to turn of execution of asp.net files.

View 1 Replies

Enumerate The Directories And Sub Directories In A Windows Form Using A Tree View?

Feb 18, 2010

I'm trying to enumerate the directories and sub directories in a Windows Form using a Tree View. I can view the directories but when I want to see the files in the sub directories I only see the files from the root.

[Code]....

View 1 Replies

Protect Some Pages From Direct Access?

May 24, 2010

I have a ASP.NET page called admin.aspx that needs to be protected from direct access.

I want it to be accessed only when the user enter his name & password in another page called login.aspx I'm working in ASP.NET with Visual Basic .NET 2008,how to do it.

View 4 Replies

Security :: Denying Direct URL Access?

Jun 28, 2010

I need to restrict access to pages based on permission given to roles based user .Roles created dynamically so that i can't restrict thru the WEB config file .i am using the custom sitemap so menu is showns correctly based on roles , but if we enter direct url in address bar we can access that page although its not permitted for the user .is there any other way to redirect to common access restrict page .

View 3 Replies

Denying Direct Access To A Webpage?

Mar 11, 2010

I have a webpage errors.aspx that needs to be protected from direct access. I want it to be accessed only when redirected to by another web page.

View 3 Replies

Web Application Architecture - Access The Files Of Project A

Aug 18, 2010

I have two projects (Project A and Project B), these projects are hosted in different locations and on different servers. Project B want to access the files of Project A. which technique is required to fulfill my requirements.

View 1 Replies

Access Denied - Creating Directories When Not Authenticated

Aug 20, 2015

As part of my new user setup, when they sign up for an account I create want to be able to create a directory under a Documents folder for them and then write a web.config file in that folder limiting access to it to the new account. However because they are still in the process they are an unauthenticated user at that point (Forms authentication), and I get an error that they don't have rights to that folder I want to create their sub-folder in. What do I need to set the folder security at to be able to create a folder and a file in that folder from code?

View 8 Replies

Security :: Deny Pages From Direct Access?

Dec 28, 2010

I have certain pages in my application that are designed to be accessed only by redirect from other pages, and not directly(i.e they must get a query string from other page, otherwise there is an exception).

So I want to prevent users from accessing them by typing the URL, but I want them to be available by redirect.

View 1 Replies

Security :: Restrict Pages Direct URL Access?

Mar 17, 2010

I have a security issue in my web application where user can enter malicious data/can change the page path directory. To avoid these i want to restrict the user by accessing/typing in the URL.

View 5 Replies

Security :: Prevent Direct Access To Embedded Page?

Oct 15, 2010

Im using an aspx page as the srcl for an image in the host page to serve a dynamically generated image to the user based on parameters they supply

ie

<img alt="" src="generateimage.aspx" id="imagegen"/></div>

Id like for people only to access the content via default.aspx and not the dynamically generated content generateimage.aspx. Any attempt to browse here directly should be redirected to an error page

View 1 Replies

IIS7 Serve Same Application Under Different Directories?

Nov 3, 2010

I wanna serve my application in ISS to be accessed from many different URL's on my web server.

eg.

http://example.com/test1
http://example.com/test2

Both these URL's get served by the same application.

I do NOT however want to just create new virtual applications to the application, because it stuffs up the user membership roles. The users and their roles must exist accross the two URL's.

View 1 Replies

Security :: Direct Access To The Page Using Role & Membership Provider?

Feb 15, 2011

I have a web app developed using role & membership provider...

this is my web.config file

<authentication mode="Forms">
<forms loginUrl="Forms/LogIn.aspx" name=".ASPXFORMSAUTH" defaultUrl="Forms/main.aspx" timeout="30"></forms>
</authentication>[code]....

So i would like that the page "pag1.aspx" is reached bypassing the "main.aspx" so If I try to digit directly on the server http://localhost/forms/pag1.aspx?C=159 ......correctly appears the login page....and the URL became..

http://localhost/Forms/LogIn.aspx?ReturnUrl=%2fForms%2fpag1.aspx%3fC%3d151&C=159 and after login I can see correctly the page1.aspx . when I try to reach the page from my browser..I digit

http://myserver/forms/pag1.aspx?C=159 .... the login page appears...but the url became..

http://myserver/Forms/main.aspx

and after login I cannot see the page1.aspx....but main.aspx

View 1 Replies

Web Forms :: Layout A Web-application Without The Direct Use Of HTML And Css?

Jul 7, 2010

Are there possibilities to layout an ASP.NET web-application without directly using CSS and HTML ? I am mainly coming from the desktop-development world and I am in the first place familiar with the usage of layout- and container-controls like panels, tables, and so on.

View 2 Replies

How To Access App_folder Files From A File In A Subfolder

Oct 26, 2010

In my project I have a website that has 2 sides, the client side and the management side. Everything is completed and works fine.

My idea was to place the management files in a separate folder (mysite.com/admin) the problem is that when I moved the files it could not compile because my admin pages inherit from a class in the app_ folder and looks like it cannot access it.

I wanted to compile the files in the app folder into a DLL but when I try, it gives me a error in the namespace System.Web.UI.Security and the WebControls ns...

How can I access my classes if my files reside in a subfolder within the same application. If I take the files out of the subfolder everything works fine

View 2 Replies

C# - Good Practice To Perform Direct Database Access In The Code-behind Of Webpage?

Jun 7, 2010

I am an experienced developer but I am new to web application development. Now I am in charge of developing a new web application and I could really use some input from experienced web developers out there.

I'd like to understand exactly what experienced web developers do in the code-behind pages. At first I thought it was best to have a rule that all the database access and business logic should be performed in classes external to the code-behind pages. My thought was that only logic necessary for the web form would be performed in the code-behind. I still think that all the business logic should be performed in other classes but I'm beginning to think it would be alright if the code-behind had access to the database to query it directly rather than having to call other classes to receive a dataset or collection back.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved