Ask a Question related to ASP.NET Security, Design and Development.
-
Umut Tezduyar #1
Why i cannot write a file, even i add a permission to that file.
My web site user should change some files in the root folder. Why the
following code is not working.
I dont want to manually give permission for the asp.net account for each
file. Instead, i want to give permission that the caller can write to the
specified file.
I have investigated the msdn and web. Is this information is hidden ?? Can
any one help me about this.
string path = System.Web.HttpContext.Current.Server.MapPath(stri ng.Empty) +
@"\";
string file = path + this.insertedcontrolName;
// Enable write permission for the file.
FileIOPermission fileIOPerm1 = new
FileIOPermission(FileIOPermissionAccess.AllAccess, file);
fileIOPerm1.AddPathList(FileIOPermissionAccess.Wri te, path);
fileIOPerm1.AddPathList(FileIOPermissionAccess.Rea d, path);
fileIOPerm1.Assert ();
// Writing to the file
TextWriter writer = new System.IO.StreamWriter (file, false,
System.Text.Encoding.UTF8);
writer.Write (this.html);
writer.Close ();
Umut Tezduyar Guest
-
write value from flash file to an external file
how can I write value from flash file to an external file like (text file or xml file) -
advice needed... cf write data to xml file for use in flash app thatuses xml file
I'm wondering if it is possible to use CF to: 1) connect to existing db; 2) get specific data from table; 3) write it to an xml file that would... -
permission to write a file (with java)
hi there i've wrote a piece of java-code that runs great if i start it from eclipse. when i pack it to a jar-file and put it in the customtags... -
Unable To Open File "..." Because It Is Already Open With Write Permission
I am trying to open a page for offline browsing and whenever I try to open a particular link I get this "Unable To Open File '...' Because It Is... -
log file sync vs. log file parallel write ?
On 11 Dec 2002 14:48:41 -0800, bchorng@yahoo.com (Bass Chorng) wrote: The writes requested by a log file sync are evidently processed by... -
Steven Cheng[MSFT] #2
RE: Why i cannot write a file, even i add a permission to that file.
Hi Umut,
Thanks for your posting. As for the file permission problem you mentioned,
are you got the "Access denied" error? In fact, this problem is caused by
the windows's file access premission rather than the .NET's CAS. So setting
the
FileIOPermission fileIOPerm1 = new
FileIOPermission(FileIOPermissionAccess.AllAccess, file);
is not necessary. We need to grant the NTFS's file access permission(
write/modify) of that file to the asp.net 's worker process account( the
machine\aspnet on WIN2K IIS 5 or the NetworkService on win2k3 iis6). After
that, you can get your page write/modify the file correctly.
Hope helps. If you still have anything unclear, please feel free to post
here. Thanks.'
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven Cheng[MSFT] Guest
-
Umut Tezduyar #3
Re: Why i cannot write a file, even i add a permission to that file.
This is not solving my problem. I have developed a control and i want my
control to write some files in the web applications root.
Do i have to inform users, which will use my control, as add, a permission
to the each file that my application will use.
What if my user deploys its web site with my control to a server that he
cannot change the permission of the files.
"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:%23Sp35mUyEHA.1884@cpmsftngxa10.phx.gbl...> Hi Umut,
>
> Thanks for your posting. As for the file permission problem you mentioned,
> are you got the "Access denied" error? In fact, this problem is caused by
> the windows's file access premission rather than the .NET's CAS. So
> setting
> the
>
> FileIOPermission fileIOPerm1 = new
> FileIOPermission(FileIOPermissionAccess.AllAccess, file);
>
> is not necessary. We need to grant the NTFS's file access permission(
> write/modify) of that file to the asp.net 's worker process account( the
> machine\aspnet on WIN2K IIS 5 or the NetworkService on win2k3 iis6). After
> that, you can get your page write/modify the file correctly.
>
> Hope helps. If you still have anything unclear, please feel free to post
> here. Thanks.'
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! [url]www.microsoft.com/security[/url]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
Umut Tezduyar Guest
-
Steven Cheng[MSFT] #4
Re: Why i cannot write a file, even i add a permission to that file.
Hi Umut,
Thanks for your response. The problem is that the file access protection is
the buildin security protection of the NTFS FILE SYSTEM. If you do want to
provide such permission for multi-user controls, one possbile approach is
to add a sub folder under the web application's root folder ( the VIRUTAL
DIR) and grant the write/modify permission of that folder to the asp.net
worker process account. Then we can put all your usercontrols that need
modify under that sub folder.
BTW, I still recommend that we don't modify the page or usercontrol's
source( aspx or ascx or code behind) at runtime. Because the web
application has the "numRecompilesBeforeAppRestart" setting which indicate
that the web app will be restarted when the number of the asp.net component
files be modified and recompiled has exceed this value, see the following
doc:
#<compilation> Element
[url]http://msdn.microsoft.com/library/en-us/cpgenref/html/gngrfCompilationSectio[/url]
n.asp?frame=true
So, I don't think modify the page/usercontrol source is a good means. Would
you consider putting the UserControl's UI change logic into the control's
code so as to make it output different content at runtime? For example, use
some properties to control the UserControl's output and we can set such
properties in Usercontrol's construct. If you have any other ideas or
concerns , please feel free to post here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven Cheng[MSFT] Guest



Reply With Quote

