Allow write permissions for ASP.NET Core API application - permissions

I am working on an ASP.Net Core 3.1 API application that downloads files. It will be saving those files to a folder outside the website. I know there will be an issue of allowing the process to write to the target directly. I found this post that talks about setting things up for .Net Framework on IIS7 (IIS7 Permissions Overview - ApplicationPoolIdentity) but I am deploying on IIS 8.5 and I am not able to find the user "IIS AppPool\DefaultAppPool".
Q1: So what exactly is the "IIS AppPool" part? Normally I am used to that being either the machine name or the domain name, but it is clearly neather since it is to be found on all machines.
SOLVED!!!!! I HAVE created a unique app pool for the app, let's call it 'upload-system'. I was going to ask how to enter it into the "Select User or Groups" and thought I should test it without quotes real quick... it worked!!!! I still want to know the answer to Q1, but I got the main problem working!!!!

The reason you cannot find the DefaultApppool is that your application pool may no longer have this application pool. If you want to give write permissions to the folder, you should try IIS AppPool\Application pool name. For example, your application pool name is Test. What you should assign to the folder is IIS AppPool\Test.
Find the application pool where your deployed application is located, and then assign this user permission to the folder.

Related

Is there any way to "Hot Publish" a .NET Core application?

I am looking to move some .NET Core applications into production and with the old .NET framework you could update the compiled DLL's for the application's code at any point.
The next time the application pool recycled, you would get your new code - or you could recycle the app pool manually.
With .NET Core, it appears that the running application locks the DLL and it cannot be overwritten until either the process is closed through inactivity, or is ended via Task Manager (Window's server here).
Is the a preferred method to publish a new version without having to set a maintenance window for all the users? This is on a Windows 2012 R2 server running the .NET Core framework via IIS 8 and the App Pool having no managed code.
For ASP.NET Core hosted with Kestrel runs in separate process and IIS works like Reverse Proxy. So there is not way for DLL release unless you implement it you your application.
Set up a hosting environment for ASP.NET Core on Windows with IIS, and deploy to it section Deploy the application, item 4.
If you want to avoid downtime simply setup two websites on IIS with same set of settings, make an update on second website, put first down, and start second.
I think the simplest way is to copy all files into a fresh folder and changing the physical path of the web site.
For example, you have all web sites under C:\WebSites, you also have a subfolder for each web site such as C:\WebSites\MyWebSite and a subfolder for each version, such as C:\WebSites\MyWebSite\V01.00.
To deploy a new version V01.01, create a new subfolder C:\WebSites\MyWebSite\V01.01 copy all files to that folder and change the physical path of the web site.
You can easily change the physical path with PowerShell:
Import-Module WebAdministration
Set-ItemProperty -Path "IIS:\Sites\MyWebSite" -name "physicalPath" -value "C:\WebSites\MyWebSite\V01.01"
This is a form of "hot publishing". Additionally you can easily roll back to the previous version if something goes wrong.
Another alternative is to use symbolic links, for example C:\WebSites\MyWebSite may point to C:\WebSiteVersions\MyWebSite\V01.00. To deploy a new version, copy all files to C:\WebSiteVersions\MyWebSite\V01.01 then change the symbolic link so that C:\WebSites\MyWebSite points to C:\WebSiteVersions\MyWebSite\V01.01, and finally recycle the application pool. Click here to see code for doing that
There is also another option called "blue green deployment" strategy. This strategy requires configuring a single server web farm and two web sites. Please see this article for a complete description.

IIS, User Permissions and Umbraco

I have installed Umbraco on my local machine but I have some questions regarding IIS and permissions if someone can help verify that I understand it all correctly. My environment is as follows
• Windows 7 Pro OS
• IIS 7.5 - I have set up a new site in IIS which has the identity Application Pool Identity for the app pool
• Umbraco v7.3.0 – The application files are located in C:\Users[myUsername]\Documents\Visual Studio 2013\Projects\InstallingUmbracoDemo\InstallingUmbracoDemo
Is the following process/understanding correct?
Add a new website in IIS and the application pool name is automatically updated to reflect my sites name.
By default this will use the identity ApplicationPoolIdentity which means that my new sites worker process (w3wp.exe) will run in an application pool that has the same name as my website in IIS
By default when I created my new site it will be added to a user group called IIS_IUSR
If I try to access my application files (that are in a folder that doesn’t not grant permission to the IIS_IUSR user group) it will mean IIS can’t access the resources until I grant the IIS_IUSR user group access
The IUSR user group is used for anonymous access and for anything anonymously requesting my website it will be added to this group
As Umbraco needs to access the internet to install the application I need to a grant permission to IUSR to allow it to do so
Partly because I don’t quite fully understand everything I’m quite concerned about the security of granting permission to IUSR on the root folder where the application files reside. Once Umbraco has installed can this user groups full permission be revoked? Does it require full permission?
I have found the following resource https://our.umbraco.org/wiki/reference/files-and-folders/permissions but if anyone else can provide an overview regarding permissions and the ISUR & IIS_ISUR work and more importantly whether I am understanding this process correctly.
Apologies if I am way of the mark – I’m just trying to learn and ensure i fully understand everything.
Many thanks
Paul
Umbraco will need permission to write files to certain folders on the server as the content/media cache, examine indexes, logs, media, etc are all disk file based.
Have you tried adding the specific AppPool user to the folders and granting permission to it?
Its usually:
IIS AppPool\MyAppPoolNameInIIS
I have had cases where that isn't allowed and I have to use IUSR, but generally this works and seems more specific and contained.

Can't access any ASPX files on my new Win Server 2008 SP2 install, enabled folder permissions/added users but still no go

Just installed Windows Server 2008 SP2
Installed IIS, ASP.NET and other necessary roles.
For my site folder I edit the permission to include
users: Network Service and a bunch of other IIS user names
a long with that Internet guest one. Fiddled around with the
application pool (Load user profile:True , Identity Network Service etc.
Also only change I made from the default fresh install settings
was installing the .Net 4 framework.
I can view regular html files etc. But should I want to make use of ASP.NET and access an aspx page, I get the following:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
When running a settings test I get:
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path. Then test these settings again.
Any ideas?
THanks..
I don't have an answer I know is the solution, but here are my suggestions:
First, have you mapped the IIS default web site to the folder containing your site?
Second, check your basic apppool settings, and make sure it's set to use .Net 2.0. It'll be 2.0 even if you're using a later version, like 4.0.
Barring that, make a new folder in wwwroot and map the default web site to that. Do not mess with the permissions. Then, make a new apppool, don't fiddle with it's settings, and assign that to the default web site. Point here is that you shouldn't have to mess with any of those settings: IIS will take care of that and the permissions.
Final thought, if that doesn't help: check your isapi filter mappings to make sure it knows what to do with .aspx. That should have been set up by default as well, but it's worth a look at that point.

IIS7/Win7 - Make sure that the application pool identity has Read access to the physical path

I am running a localhost instance (so domains are not my issue!) on my laptop utilizing Win7 and IIS7. I am getting authentication errors on my website and my one virtual directory.
default website - localhost:80 c:\mydirectory\localhost
virtual directory - c:\mydirectory\weborb30
Please notice these are not under c:\inetpub\wwwroot!
Now, I did some googling/binging and discovered that I needed to add my [machinename$] to the ACLs. (Hope I said that right.) I did that, even though it is a domain thing. Nothing changed. I further read that IIS7 is now using ApplicationPoolIdentity and I tried finding that on my local machine - no luck there. So, I changed the App Pool to run under another built in account. Now, not only do I get the Authentication error I can no longer AttachProcess to W3WP.
How the heck do you PROPERLY setup VS2005, IIS7 on a WIN7 box to run locally???
I was having a similar problem and ended up fixing it by giving read permissions to the "IUSR" user and "IIS_IUSRS" group.
I'm not really sure why this works. It seems odd needing to give permissions to IUSR when I thought it would have been included in the IIS_IUSRS group. I think part of it relates to the account the application pool runs as (e.g. "IIS AppPool\Classic .NET AppPool" for a classic .NET application pool in IIS 7.5 / Windows 7), but I'm still unclear.
This StackOverflow question seems to be related.
Before you made changes to the app pools, all you probably needed to do was add read access to your physical directory for the "network service" account (that is the default account used by asp.net on vista & win7).
I think what you may be looking for at this point is this:
aspnet_regiis -ga <useraccount>
The -ga switch tells aspnet_regiis to configure all the security for asp.net. Usually you only need to do this stuff when you are using impersonation in your application, but if you are changing the default user for the application pools then you are effectivly doing the same thing IIS wide.
The best complete documentation I've found is on MSDN. It applies to the previous version of IIS, IIS 6, but it is pretty easy to apply it in IIS 7 environments
Just try to restart the IIS here: IIS Location to restart and don't use iisreset etc
if that doesn't work try to add it here first, and then Restart (right click again and restart through the interface.) then get it back to the correct permissions.. Restart again in the same way.
I hope it helps it solve most of the bugs for me in that subject..

WCF Threading current owner

I hosting a WCF service on Windows 7 IIS. When the service is trying to write to a config file and getting the error:
"Access to the path 'C:\Program Files (x86)\MIMS\Master\ahug_uqt.tmp' is denied."
This is not the name of the config file although I assume ConfigurationManager is creating a temp file then updating this to the real config file.
Anyway, I have checked that neil-laptop (that's my user), ASPNET, NETWORKSERVICE and LOCALSERVICE have full control over the programs folder and they do. When debugging into the service it shows the current thread principal as neil-laptop. This should not be the case as it is an IIS process.
So, how can I see which user the thread is running under so that I can give this the appropriate permissions. Bearing in mind also that the above worked on Win2003 and XP when I gave the users full control to the folder. Darn you Windows 7.
Hopefully,
Neil.
I modified the user that the IIS App Pool is running under to use the NETWORK SERVICE account and gave this account permissions to the appropriate folder.
Simple really. Not sure about security implications for this but the NETWORK SERVICE account is very limited in it's permissions so should be fine.