ASP.NET Access to the path denied, on Web Server - asp.net

I am having a problem, that is when I deployed my asp.net 4.0 application on my web server i am unable to write to App_Data folder. Actually it has an xml file which I am trying to write some information into. I am getting the following error.
Access to the path 'C:\HostingSpaces\hosterind\mydomain.com\wwwroot\App_Data\ErrorLog.xml' is denied.
I tried searching every corner for a possible solution before posting on stackoverflow but i am unable to fix this. Searching similar questions on internet (stackoverflow too) i concluded that i need to handle it through IIS as everywhere it was quoted on internet to grant permission to App_Data folder through IIS Manager. As accessing IIS Manager of your web hosting server is impossible, i supposed people are referring to my local IIS server. So, i copied my project which i was developing in visual studio from location: C:\Users\DanComputer\Documents\Visual Studio 2010\WebSites\MyWebProject and pasted into C:\inetpub\wwwroot. Then i located my project in IIS Manager by selecting DefaultAppPool as application pool. I changed my App_Data folder permission to allow full control for IIS_IUSRS(DanComputer\IISUSRS). Then i copied my App_Data folder to my web hosting space using ftp software but it didn't solve my problem. I tried many thing even changing permission to allow full control for everyone but it did't work and i am still getting the same error. Any help please?

You need to know what is the identity of the Application Pool of your app. You can get this information from IIS or console. It is possible that your hosing company may have a control panel that can give you that information.
Then you need to give permissions to the account in the app pool identity the names will be the same or at least be very similar to what you saw in IIS:
So using my examples above I will have to give permissions to Local Service or Network Service to read/write my app_data folder.

Related

Support with hosting an ASP.NET application from my PC at work using IIS Express

I'm fairly new to developing with ASP.NET and in general. I have created a simple data-driven web application that will be used to display images the colors of which will be changed depending on certain criteria. I used Visual Studio 2019 to create it. When I test/run it from within VS 2019 using the "play" button, it runs perfectly and the page opens in my browser just as you would expect.
My issue is that I'm trying to deploy it to the IIS and host it from my machine here at work, so others can access the pages. I have published the application to a local file on my C:\ drive. I then open up IIS Manager and create the website by pointing to that local file. Now, when I choose to browse that site from the IIS manager, at first I was getting an error saying that access is denied.
Then I followed the instructions to configure the security on that local file folder to allow IIS_USRS to access the file, but when I run it, I just get a page that tries to load indefinitely.
What am I doing wrong? If I point the IIS Manager to the files after saving them to a location on my company's network, I again get the access is denied error.
Do I understand it correctly that IIS needs permission to access the files? If so, how do I configure it that way other than what I already tried? If I need to provide further information, please let me know. Thanks so much for your support.

ASP.NET Access to path '\\xxxx' is denied

I know this has come up in other questions, but none seem as simple:
I have a UNC share on another machine, with security set to Full Control for Everyone. If I log into my web server, I can access this share.
However when I try to access it using Directory.GetFiles(path) in the ASP.NET code, it returns an Access to the path \\xxxx is denied. error.
Also oddly, when I run the same website from my local visual studio web server, but pointing at the same path, the directory can be accessed fine.
What am i missing here?!
Add IUSR, IIS_IUSRS as suggested by Carlos487 and Network Service as well with full control on the directory that you are trying to access with your application. Hope this helps.

How to set correct file permissions for ASP.NET on IIS

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code : 0x80070005
Config Error : Cannot read configuration file due to insufficient
permissions
When add new web application in IIS 7.5 and run it, this page shown to me, how to solve this problem win7 ultimate visual studio 2010
The message is clear.
Cannot read configuration file due to insufficient permissions
How to solve it.
Every asp.net application is run under one pool assigned to it, and each pool is run under a specific account.
Open the IIS, locate the pool under which your app is try to run, see the user that is assigned to that pool, and give read permissions to that user on your full site directory tree.
Especial for the web.config
The web.config, its the configuration file that message says, must have (and) write permissions.
So you locate web.config on the root of your site, right click on it, go to permissions and give on the pool-user, the write capability. The pool user, is the user under the witch the pool is run, as I explain below.
More details
To been able to run a public asp.net site with IIS, each file on the directory must have permissions for two accounts.
One account that is permitted for public access, and the account that assigned to that application pool have.
To find/assing the first account you go to your iis site | Authentication | Edit, and see or change it as you see on that screen shot.
Now note that name and we going to find the user under with the pool run.
Go the your IIS Site and click on the Basic Settings to find the pool name, then go to the IIS | Application Pools and see the Identity column, and note the name of the user under the witch your site is run.
Now that we have the two users names we go to the root of the site and set the minimum of permissions that is the read as
Some Notes
If the IIS_Public_ACCESS_USER is not give read permission the site is run, but ask for password
On some directories you need and write permissions, if you let for example your users upload images, or keep on App_Data, some database files. Only for that directories you give and the write permissions to the IIS_POOL_USER.
Some directories, like the App_Data and App_Code have direct protection from asp.net and they not allow anyone from the client side to run or view whats is in there.
On the public directory that allow write access to your user add one web.config and totally disable all the running of asp.net files.
More to read for the directories that give write permissions I've been hacked. Evil aspx file uploaded called AspxSpy. They're still trying. Help me trap them‼
It looks like your IIS_User doesn't have the necesarry permissions to access your website in C:\Users....\Visual Studio 2012\Websites...
Also make sure your application is running the correct .NET version (2.0, 4.0, ...)

Cannot read configuration file due to insufficient permissions

Okay, I realize there are many questions relating to this error, I have read several questions and answers without resolving my problem.
I have a MVC site that I'm trying to debug on local IIS web server.
I check the option to use local IIS in the project properties and I've created a virtual directory in IIS.
The error I get in Visual Studio is:
Unable to start debugging on web server.
In IIS i try browse the site but get the error:
Cannot read configuration file due to insufficient permissions
Config File \?\C:\Users\Mike\Documents\Visual Studio 2010\Projects\MvcApplication1\MvcApplication1\web.config
I've set permissions for the pool identity on the web.config and whole project folder.
I've tried localsystem identity, no luck!
Please help me resolve this. I've spent several hours trying to fix this.
I found that if granting read permission to IIS_IUSRS still does not help. You need to also check that the web.config file is not encrypted. You can see if the file name is green in Window Explorer, it means the file encrypted. You can also do right click at the file, select Properties… / General Tab / Advanced… Make sure the "Encrypt content to secure data" unchecked.
It works for me once I uncheck that Encrypt box.
Maybe this will help. Look here, here and here
You also might have to grant ISS_IUSRS right to C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config and then do a iisreset
Edit:
Do you have the right Application Pool Identities? Read more here
For local development I've used pritty straightforward solution - just set IIS Application Pool to LocalSystem, set permissions for site folder (ISS_IUSRS - all) and it's worked for me
I only ran into a different set of issues with IIS_IUSRS. So I just published the site under a whole different folder, off the root, and the issue went away!

403 Forbidden in SharePoint After Deploying Website

We have an old ASP.NET application hosted in IIS6/Win2k3. It's a document generation application that uploads the documents to SharePoint 2003. The application uses an application pool under the user sharepointservice, which is the administrator of the SharePoint site. The web application, which has been recently migrated to .net 2.0 from 1.1, uses NTLM authentication to identify our intranet users.
As the IT administrators are on holidays, I, the developer, has been given local admin rights to the Win2k3 box. The issue is, whenever I deploy the website, though the documents are uploaded appropriately to the SharePoint site via the application, the users are not able to download them. The error is
HTTP Error 403 - Forbidden: Access is denied
I know the IT guys use a service account, not their domain user accounts.
I have already tried to modify the permissions in IIS for that website. I even put Everyone and <Domain>\Users to have read access to all of those folders, to no avail. I've scoured the net, there are no definitive answers. Am I missing something else?
I hate answering my own question, but this did it for me:
The application pools for the SharePoint site were modified from the default. So I reset them, including the AppPools for _layouts, _vti_bin, and _wpresources. Their AppPools are now the default, and are the same.
This link gave me the lead.
You are probably being prompted by permissions for the file system. Check the directories where IO is happening and make sure the user sharepointservice is using in the app pool has read/write permissions.
I just had this problem and solved it after following these instructions:
http://support.microsoft.com/kb/2543306
It seems the webapplication took so long that it hadn't created everything correctly when the IIS timed out. So I was receiving strange errors like yours.

Resources