Access to the path 'C:\Sites\content\ServerIpAddress.txt' is denied - asp.net

I create a web site that in Default web page of it i try to access to ServerIpAddress.txt file that is on server . now when i run my project on local host it work correctly , but when I upload it on Server(free host) i face with
error. can some one help me ?

You most likely do not have permissions access files on the shared server due to security issues. Consider moving data from that file to web.config app key.
or access the file as a relative path to your site. The remote sever will most likely not have the same folder structure as your local machine.

The account that is being used for the worker process of the web site has no (write)access to the file.
Configure the file (or folder) so that the ASP.NET process has access.
Another thing to look at is whether or not the path as stated in the code is the actual path on the server.

give full permission to ServerIpAddress.txt file. it will work.

Right click on content folder. Click Properties. Then from General tab uncheck the Read-only checkbox.
Then go to Security tab and Allow Write permission for your ASP.NET process.

Are you using a database? In that case how did you set up permissions for app_data folder? You have to set permissions in the same way.
If you are not able to do that, try moving the file inside of app_data folder and then check.

Right click on .txt file and select security and add network service .restart iis and try.It will work.

Related

Application hosted on IIS not able to read some html files placed on the same server in diffenrent folder

I have an ASP.NET application hosted on IIS. And have some html files in a folder under "c" drive on the same server. My application try to read those files and display some content from those files onto the webpage. But it seems like application is not able to read those html files. I have tried with all the permissions.
LIKE : giving that folder "Network service" "Network", "ISUR" full control permissions. But application is displaying
404 File or Folder not found error. Please suggest.
Thanks
Under file Properties > Security > Group or user names > make sure that user IIS_IUSRS has access to the file.
And remember that it's not a good practice to allow webserver to access files on C.
Webserver should be limited to inetpub.

opening folder in web site structure in Windows

I am trying to set up a hyperlink to open a Windows Explorer, so that it can display a folder on the web server that is within the web site.
So in IIS, we have inetpub/MyWebSite/subFolder/Data/
I would like to allow for a web page hyper link to open the folder /Data
I can set up a user account on the web server and only provide access to this folder. I can use ASP Membeship to restrict access here, and/or assign the Network Service acccount access.
I don't really care who can see this folder as anything that gets placed in here will only be temporary, and nothing is "Mission Critical" just a file that the web site will read and write to and then it gets deleted.
Any and all ideas and suggestions will be tested.
Thanks for any help.
Build a representation of the folder's contents (using a DirectoryReader and CSS) and display that. Don't actually try to display the physical folder.
this sounds like FTP, and if it's on an intranet, why not create a share? much less work.

asp.net log files permissions

Our asp.net app writes errors to a text log file in the web sites root folder. This has lead to all sorts of permission problems, different flavors of IIS and windows allow different things by default.
So what I am wondering is there a location somewhere in Windows where all types of users can write a file without any extra permissions that will also work for all IIS and flavors of windows?
I am thinking of the ApplicationData folder, but did this exist in Server 2003 ?
Thanks,
AJ
The easiest solution would be to use the App_Data subfolder of your web application for this. By default it's not viewable from the web, so Internet clients won't be able to read the logs.
Depending on your deployment method, you might have to change the permission to allow write access to this folder (to the user under which your web application is running).
Alternatively, there is a place where every user can write to: It's that user's temporary folder, which you can access through Path.GetTempPath. This, however, does not sound like a suitable location for log files.
You should always first think about wwwroot folder (%systemdrive%\inetpub\wwwroot) because it has the required permission.
The permission you need is to set a full control for IIS_IUSRS
Edit: you can simply give Everyone Full Control (not recommended at all) but this solves most of ntfs permissions issues with IIS

Folder permission on server while uploading?

I want to upload files in my Asp.net application on server but I have to grant it R/W access so that I or anyone can upload files in it. Is there any way that I write some code or configuration lines in Web.config which solve this permission problem?
You have to set the permissions on the folder for the account under which your application is running. This is an operating system level, and hence nothing can be done about it in Web.config. Be careful to only set the permissions on the one folder though, as your effectively opening it up to the internet through your application.

ASP.NET impersonations?

I have a aspx file that suppose to write to a file in the server while loading. On the local machine it works fine, but when i deploy it to a live server it gives me an exception "Access to the path 'd:\DZHosts\LocalUser\asafz83\www.asafz83.somee.com\lala.htm' is denied."
WHen i asked my serverAdmin for the reason - he told me to remove any impersonation from my web.config file. Well, my web.config file doesn't contain any impersonation, so i'm really confused:
What can i do in order for this sealy-stupid application to work?
thanks!
Assuming the id being impersonated has appropriate access to the server & folder that you are writing to, you have to allow your web server to be trusted for delegation.
See this for Windows 2003 server:
http://technet.microsoft.com/en-us/library/cc738491(WS.10).aspx
I've had the same problem a couple weeks ago..it took us a few days to figure out that it's just a checkbox that needed to be set.
You don't have to go through impersonation.
Create a folder in your website, let's call it "Files". You can access its path via Server.MapPath to do whatever saves you want in that directory.
Server.MapPath("~/Files")
When you deploy on IIS, you have to apply Write permissions on the folder "Files" for the ASP.NET user.
Essentially your server admin is saying that you may not have the permissions needed to perform the operation / access th path in the error.
Is this a valid path that you think you should have access to, if it is then there is a chance your application is configured wrong.
Your admin guy is basically saying ...
In the web.config file check that you have not got something that reads like this :
if you do, remove it because you re trying to impersonate / get asp.net to run within the context of the guest account for internet users connecting to the server.
There is more on the topic here ...
http://msdn.microsoft.com/en-us/library/xh507fc5(VS.71).aspx
Something worth noting is that application configs "inherit settings from parent applications", this means if you have a web app running that works with this, and then in a child folder deploy a new web app that does not have the right to do this then it will break because of the parent applications settings.
This may or may not be relevant to your situation but i feel its worth noting.

Resources