asp.net iis error - asp.net

I am using asp.net 2.0 and IIS 7 on vista 64 bit.
everytime, when i try to open page in browser, i get following error.
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. You might not have permission to view the requested resources.
Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control Lists). Ask the Web server's administrator to give you access to 'C:\example\WebApplication1\WebApplication1\Default.aspx'.

Does your application pool's user have read permissions to the files you're trying to serve? By default, this should be the NETWORK SERVICE user.
Your ASPNET user will also need access.
Permissions can be set here:
Right click the directory or file --> Properties --> Security tab

You need to give the permission to user name "Internet Guest Account" on C:\example directory on an inner directory given you have used the same user in the IIS anonymous setting.

Give your aspnet local user permission to the directory you're trying to access.

You need to add permission to the user binded with Application Pool on folder in which is your website.
The name of the user is usually IUSR, NETWORK SERVICE or IIS_IUSRS.
Permision to the root: Read and Execute, List folder and read
Permission to the root/App_Data: All
Or another approach could be to set the username in the application pool (Advance setting -> Identity) to the username which has rights to read the directory. You may need create new application pool.

Related

Cannot get Orchard CMS site to load on Network Solutions Windows Hosting

I get the following .NET error when trying to load my Orchard CMS website:
Access to the path '\\.........\www\App_Data\Dependencies\Lucene.dll' is denied.
Exception Details: System.UnauthorizedAccessException: Access to the path '\\WDP\DFS\30\7\4\5\3024678547\user\sites\5481517.site\www\App_Data\Dependencies\Lucene.dll' 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 and IIS 7, and the configured application pool identity on IIS 7.5) 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 access to a file, right-click the file in File 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.
How do I actually go about granting access rights? I've googled and found I should go into the server and right-click on the directory and edit the properties. BUT, I am in a shared hosting plan and don't think I can do that.
Am I pretty much at a dead end?
Things I've tried:
Setting file permissions through FTP, but I get a:
500 'SITE CHMOD 777...command not understood
I've downloaded and installed IIS Manager and successfully connected to my site, but still did not find any options to set permissions in there.
I've also called Network Solutions, but all I was told was to try to do the file permissions settings (as I mentioned above).
Thanks in advance.

CSS not referring after hosting in iis

I m using vs2010 and iis 7
i hosted my web app in iis 7
like http://localhost/TestUI/login.aspx
But the css file not referring..!
I opened the developer options and tried to see the css file
like http://localhost/TestUI/css/style1.css
It throwing error like
401.3 - unathorized - You do not have permission to view this directory or page because of the access control list (ACL)
configuration or encryption settings for this resource on the Web
server.
I have tried many ways to solve it..
Gave access to IUSR to wwwroot folder in properties -> security
Changed Anonymous Authentication to Application pool identity
Used (~) in the css url in aspx page
But don't know how to solve it ! what to do !!
As per MSDN
This problem occurs when permissions for the file that the user is trying to access are denied to that user. This error message differs from a standard 401 error message, in that, the user has been logged on to the server, but the resource that the user is trying to access is restricted. For example, if only Administrators and LocalSystem have access to a file on the server and a user, who is a member of the Users group, tries to access it, the user receives a 401.3 (provided they can log on to the server).
The resolution states to check the NTFS permission on that file. Make sure users can access the same.
I found a thread that could help you with the solving the same. As per the thread,
IIS 7 also creates "IUSR" as default user to access files via IIS. So make user IUSR has read access to files/folders.
How to check if IUSR has read Access? Right Click -> Folder -> Properties -> Security Tab See if IUSR is in Group or user names list, If No.
Click Edit -> Add -> Advanced -> Find Now -> Select IUSR and click OK four times

IIS: System.UnauthorizedAccessException: Access to the path

I have a website and it sits on the IIS Server and I have a folder on another server the file server. I have set the Virtual directory to the folder on the fileserver. This application both servers are on the same domain, but in the future I will have serves that are not on the same domain.
I have tried to set up local users on both machines and set up the app pool to use the local accounts and I get
System.UnauthorizedAccessException: Access to the path is denied.
and
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
I have set the virtual to connect as the local user and get the same error.
I have setup a domain user and then set the app pool to use the domain user and set to use pass through and when I test the settings in Directory Browsing it says everything is good but I get the same error from the webpage.
I have setup a domain user and then set the app pool to use the domain user and set to the connect as to the user and when I test the settings in Directory Browsing it says everything is good but I get the same error from the webpage.
I have set the apppool to use my login and it works with pass through permissions.
Is there something I am missing.
You need to set the folder permissions in your separate folder to give access to the "computer$" account of the server where your application is hosted.
See here: https://www.iis.net/learn/manage/configuring-security/application-pool-identities
application pool identities also use the machine account to access
network resources.
So in the server where you have your data files you should set the folder permissions to allow access to the machine name where your website is hosted.
I had this same challenge when deploying a web app using IIS on a Windows 2012 Server.
The issue was the App Pool Account did not have Full rights to the Website Root.
All I had to do was to go to the directory where the Website Root resides and then right-clicked on it. Next, I selected Security and then gave the IIS-Users group full access to the directory.
For me IIS-Users group contains all Users/App Pool Accounts that are created in IIS.
That's all.
I hope this helps
I have created a domain user specifically for the the virtual directory and it appears to work, but is this best practice?

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, ...)

Access shared folder from application deployed in IIS

I have a problem when I try to access a file from a shared folder in a local network.
When I run the application in Visual Studio it works fine and I can download the file, but when I deploy the application to IIS, it simply doesn´t work.
I don´t understand why, cause I give full permissions to all users, including NETWORK SERVICE and IIS_USR.
I'm currently using my computer to test this. It has Windows 7 and running IIS 7.5. The shared folder I'm trying to access is on a Windows Vista installation which doesn´t have IIS installed.
The code to download file is this:
protected void button_Click(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=S10.png");
Response.WriteFile(#"\\192.168.1.82\Machine\file.png");
Response.End();
}
and it gives me the following error:
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Acesso negado
ao caminho '\192.168.1.82\Machine\file.png'.
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 and IIS 7, and
the configured application pool identity on IIS 7.5) 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.
To grant ASP.NET 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.
Please someone could help me.
Thanks in advance.
You have given access rights on the file system (full control is overkill for this, read or modify should be fine), but you will likely find the share permissions are still at the default of read only. You need to change the share permissions.
Read this for more info.
EDIT: The reason it works ok when debugging is because it's using the account you are logged on with, not the aspnet account in VS.
Create a new app pool, running under a service account which is a member of the IIS_WPG group on the IIS server and has permissions on the share you want to write back to (remember to set the service account to password never expire). Give the IIS_WPG group Read & Execute, List Folder Contents, and Read permissions to the Web site directories. Change the web app to run in this new web pool.
solution 1:
You can define a domain user. Let IIS server run with this user ( through Pool identity or 'connect as'). give this user access rights on Shared folder.
Solution 2:
Add IIS server account into user group of the server that contain shared folder, Give this user access right on shared folder.
If the file and the Machine folder is in C Drive, then you also need to give permissions to the root folder containing this file path because C Drive is usually read/write protected as it has System Files in it.
So for example if the file is in the path C:\Machine\file.png.
Then you need to add and give relevant permissions to IIS users group to Machine Folder and not just to the file i.e., file.png.

Resources