|
Yes, i tried and it throughs an exception.
|
|
|
|
|
i am using vs2003
i want to write some text into an existing file present at server side using asp.net but it gives me an exception named
----->System.UnauthorizedAccessException: <------
so i need how to get permission to write file to server
any suggestions are also welcome
the code i used is given below---
Dim fs As New FileStream("C:\Inetpub\wwwroot\wa_readfromcsv\textfile_as_csv.txt", FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
s.WriteLine("This is an example of using file handling concepts in VB.NET.")
s.WriteLine("This concept is interesting.")
s.Close()
------- the exact error shown is ---------
' Exception Details: System.UnauthorizedAccessException:
' Access to the path "C:\Inetpub\wwwroot\wa_readfromcsv\textfile_as_csv.txt" is denied.
'ASP.NET is not authorized to access the requested resource.
'Consider granting access rights to the resource to the ASP.NET request identity.
'ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
'or Network Service on IIS 6) that is used if the application is
'not impersonating. If the application is impersonating via <identity impersonate="true">,
'the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
'To grant ASP.NET write access to a file, right-click the file in Explorer,
'choose "Properties" and select the Security tab.
'Click "Add" to add the appropriate user or group.
' Highlight the ASP.NET account, and check the boxes for the desired access.
thanks in advance for your help and time...
|
|
|
|
|
The error message tells you what you need to do. Basically, the ASPNET user does not have write permissions for this directory. You need to grant this user permissions to the directory. Follow the instructions in the error for granting ASPNET access.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: The error message tells you what you need to do
There are none so blind as those who will not see.
|
|
|
|
|
thanks for your reply ..
about the suggested solutions
for first suggested way--- i dont know how to grant permission to the user .
for second way--- i dont think that changing in my system will solve the problem globally because application is web application .does the second solution mean that i need to change in explorer of system where i installed the application ...i dont think so ..even thought i do it is something like i will only use the application at client side it appears...
...so please explain me clearly what the error message says me to do.
|
|
|
|
|
rama charan wrote: about the suggested solutions
for first suggested way--- i dont know how to grant permission to the user .
for second way--- i dont think that changing in my system will solve the problem globally because application is web application .does the second solution mean that i need to change in explorer of system where i installed the application ...i dont think so ..even thought i do it is something like i will only use the application at client side it appears...
...so please explain me clearly what the error message says me to do.
OK - as you are running this as a web application, then fixing it at the server is enough. Right-click on the directory that you are trying to write this file to, choose Properties and select the Security tab. Click the Add button and choose the ASPNET (if you are running IIS5) or Network Service (if you are running IIS6) user. This user is a local account. Select OK and then choose the relevant permissions at the bottom of the properties dialog. Once you have chosen the permissions to grant, click OK.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
that was a very clear description thank you very much
but its still not working ....
what does this mean in the error description something with "impersonating"..
" that is used if the application is
'not impersonating. If the application is impersonating via ,
'the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user"
i dint get exactly which user to modify ...just assume that i am using a simple webiste and its accessible to all ..so no authentication.
but may be the code has any issue please check the 5 line code also
assume file is already present.
thanks for your effort..
|
|
|
|
|
T-SQL transaction vs ADO.NET transactions
What is the better to use between them?
waiting for prompt reply
|
|
|
|
|
Dinuraj wrote: waiting for prompt reply
Please don't put things like this into a question. The people on this site give their help freely, and in their own time. If somebody can answer you, they will.
Anyway, you would use a T-SQL transaction when you can accomplish everything inside the same top level stored procedure. ADO.NET transactions allow you to wrap multiple stored procedures into the same logical transaction.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi all,
I want to publish my web site and i dont want users to be able to see my connection string in web.config. How can i do that in an easy & simple way. Any encryption code or another way?
Thanks
SH
|
|
|
|
|
The code you need to encrypt/decrypt your connection strings section in your web.config file looks like this:
public void EncryptConfigSection(bool bEncrypt)
{
string pathToConfigFile = "~/";
Configuration config = WebConfigurationManager.OpenWebConfiguration(pathToConfigFile);
ConfigurationSection connStrings = config.GetSection("connectionStrings");
if (true == bEncrypt)
connStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
else
connStrings.SectionInformation.UnprotectSection();
config.Save();
}
Sebastian M.
|
|
|
|
|
Hi there,
.NET supplies System.Security.Cryptography namespace to do that...
<< >>
|
|
|
|
|
hi
i want to validate a Textbox which is in a webpartZone, i am able to do that when my aspx page is not inheriting from master page, but when I am using a aspx page with master page and my Textbox in side a webpartZone I am not able to valdate the text box .it through an error Unable to find control id 'TextBox1' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1' please give some .
Regards
Smruti
Smruti
|
|
|
|
|
Hello.
Do you have another "TextBox1" somewhere on your page? Perhaps in the Master page itself? If so - ASP.NET renames the controls in order to get a unique ID. It should automatically rename your RequiredFieldValidator1 reference to the control as well. But perhaps this does not happen as expected. Anyway you should go check it out. I've found the best way to debug this, is to try and rename your control to something logic eg. "txtName" - that way you ensure, that you decide the names, and not Visual Studio, because, well, it's best the other way around.
Best Regards
Soeren
|
|
|
|
|
Dear All
I want to creat a regular expression for a dropdown list
My first item in the dropdown list is "Please Select One..."
So i want to create a regular expression to validate this
i mean, i don't want to keep the dropdownlist with it's default selected value, i want to force the user to select one item
And if there is a better solution for that, please tell me about it
Thanx in advance
Best Regards
3ala2
|
|
|
|
|
Hi
you have to use requiredfieldvalidator and set the property Initialvalue = "Please Select One..."
Regards
smruti
Smruti
|
|
|
|
|
try this javascript and let me know....
function ValidateDegree(source,arguments)
{
if (document.Form1.DDLDegreeName.value == 0)
{
arguments.IsValid=false;
return false;
}
else
{
arguments.IsValid=true;
}
}
<asp:dropdownlist id="DDLDegreeName" runat="server" width="330px">
<asp:customvalidator id="CustomValidator1" runat="server" errormessage="Choose Degree" display="Dynamic"
clientvalidationfunction="ValidateDegree">
|
|
|
|
|
Thanx for the quick response
Where to put this code?
samerh wrote: ClientValidationFunction="ValidateDegree">
and what event to call the previous one?
and what if i had other valdators? would they still work fine?
Thanx again
Best Regards
3ala2
|
|
|
|
|
use custom validator with ClientValidationFunction="ValidateDegree".
It will work.
Man i need a favor on Any idea on how to encrypt password in web.config?
<asp:dropdownlist id="DDLDegreeName" runat="server" width="330px">
<asp:customvalidator id="CustomValidator1" runat="server" errormessage="Choose Degree" display="Dynamic"
="" clientvalidationfunction="ValidateDegree">
|
|
|
|
|
|
Hi all
I am developing one installation wizard. I have one issue. If i click the next button I made the current form visible = false and creating instance for the next from and showing the form. There problem I facing is, I dont know how to show the previous form by hidding the current form. Can anybody help me please....
Thanks
kesavan
kesavan
|
|
|
|
|
Why don't you put a tabcontrol on a single form, and navigate between the tabs if required. You can hide the tabs so the user won't see that you're using a tabcontrol...
|
|
|
|
|
Hi,
I am using smtpmail server in my application i have file control through which i can attach the file,after attaching if i click "Add" button that selected path was added in the following datagrid here i am facing problem if i attach 3 files after clicking 3 times "Add button" the 3attachments path was successfully added to the datagrid but the last attachement that is 3rd one is only be attached to mail but i have to concate the three paths how the concate the selected three paths can any body help me from this situation please
thanks,
Eswarattaluri
|
|
|
|
|
Create Attachment objects for each attachment and add them to the Attachments collection of the MailMessage object.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
i have a datagrid that their columns are unlimited and now i want create a crystal report form for that.if i had limited column i can desing the columns but i dont know haw many coulmns i will have and its count be in database.may be 3 or 4 or ... . do any body know what shoul i do?
|
|
|
|