Running .NetCore API on IIS 403 Forbidden - iis

I can't seem to get my netcore api up and running on IIS.
I'm deploying from Azure DevOps
The files from the build artifact are present on the remote server though I ran build and not publish, but it seems like everything is there.
I've created an Application Pool with No Managed Code in the .Net CLR Version,
I've given permissions to the wwroot/api directory for read/write/execute to IIS_IUSRS
I've installed the AspNetCoreModuleV2 and restarted the service(s)
If I add an index.html file to the site I won't get the 403. Makes sense.
If I enabled directory browsing I can see all of my files.
There aren't any views for the site, it's just a headless API. I'm not sure if there's anything else that I need to make sure is added/installed for it to run.
Thoughts?

Related

Why are my Azure deployments to local IIS failing?

I'm deploying an asp.net core web app to local IIS 8.5 with an Azure pipeline. Deployments are failing because the .dll of the site is locked by IIS. This is despite the fact that I explicitly stop the site, using a IIS Web App Manage task, before the deployment.
The specific error is...
ERROR_FILE_IN_USE Web Deploy cannot modify the file'MyApp.dll' on the destination because it is locked by an external process
Why is this. What do I have to do to get IIS to release the .dll and let my pipeline do its thing?
Update
I've tried a powershell script to create a App_offline.htm file. The file's created, but the following Web App Deploy task still fails with the same error.
Ok fixed it. I needed to stop the app pool in addition to the website. So in the IIS web app manage task, in Additional appcmd.exe commands, put
stop apppool /apppool.name:"MyAppPool"

Azure app service startup command (required)

I am deploying my ASP.NET Core 3.1 app to Azure App Service. While creating the new app service, I chose Linux as Operating System. In deployment center, when I deploy the app, it prompts me to enter a startup command. Everywhere I read about it it says startup command is optional. But when I deploy, it doesn't get further without this.
I have recently deployed other app services on windows and this was not the problem then. The startup command I am entering is dotnet <project.dll>. It deploys successfully. But after the deployment whenever I hit an API endpoint, it gives 500 Internal Server Error.
My question is:
What is the purpose of startup command? Why is this returns with 500 when deployed to linux.
S
It seems your startup command is correct refer to this.
You could check if this setting had been set already in Configuration, and check if the .dll file name is correct. As far as I known, this setting is necessary under Linux environment.
For 500 Internal Server Error, it's a error from server side, sometimes it means your web app is not prepared, and restart it would solve the problem.
If not solved, check the wwwroot file structure in kudu. ->.scm.azurewebsites.net If the file structure not correct, try another way to deploy.
Update
As your own reply, you connected your app to database. If issue still here, try add sql server policy like this:
I diagnosed the problem. My deployed app service is not whitelisted to access database. That is the reason for 500 Internal Server Error

Azure app service: how to add custom Handler mapping to process TXT files?

I want to use ASP.Net Directives in a TXT file. Typically, I would add a handler mapper for that. But how can I do that in Azure App Service? Adding the following handler (D:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll):
generates the following exception:
Most likely causes: IIS received the
request; however, an internal error occurred during the processing of
the request. The root cause of this error depends on which module
handles the request and what was happening in the worker process when
this error occurred. IIS was not able to access the
web.config file for the Web site or application. This can occur if the
NTFS permissions are set incorrectly. IIS was not able to
process configuration for the Web site or application. The
authenticated user does not have permission to use this DLL.
The request is mapped to a managed handler but the .NET
Extensibility Feature is not installed.
Things you can
try: Ensure that the NTFS permissions for the
web.config file are correct and allow access to the Web server's
machine account. Check the event logs to see if any
additional information was logged. Verify the permissions
for the DLL. Install the .NET Extensibility feature if the
request is mapped to a managed handler. Create a tracing
rule to track failed requests for this HTTP status code. For more
information about creating a tracing rule for failed requests, click
here.
and I don't think there is much I can do with the suggestions.
So what's the right way to map static file to ASP.Net pipeline in Azure App Services?
In Azure web service, we don't have to use aspnet_isapi.dll to use ASP.Net pipeline because the built-in server is IIS. We can see below screenshot, i published a ASP.NET Core to Azure web app, and we can see the Microsoft.Owin.Host.SystemWeb.dll under the root folder, this means that my ASP.NET Core application is hosted in IIS. (Besides IIS, are there any other better servers to support OWIN?).
Thus, if you are using ASP.NET Core and you want to use IIS pipeline, i think it is impossible because the IIS is just a reverse proxy server in this situation. You need to delete the Microsoft.Owin.Host.SystemWeb.dll and modify the web.config file (I tried and worked) but doing this will cause your ASP.NET Core application crashing.
If you are using ASP.NET Framework or just a simple static web, we can do it with our code and web.config.

Why do I have to publish MVC project twice?

I have noticed that when I am publishing an MVC project to a 2008R2 IIS server I have to do it twice in a row.
I am publishing by file system, and have selected to Delete all existing files prior to publish and precompile during publishing.
IIS and the site is setup to use Windows Auth.
If I only publish once and browse to the site I receive a 403 Forbidden Access error.

Manually deploying Umbraco website on IIS - dashboard, js and css not working

I have an Umbraco website with an SQl db. I backed up the DB and imported it on the SQL server on the server here. I then copied all the files of my umbraco folder and placed them in a folder on the server here as well.
I then made an 'application' in IIS and gave it an 4.5 application pool (integrated). I linked it to the folder on the server where all of the files are.
When I browse to the site I get to see all the content, also the dynamic content from the DB, but none of the mark up is applied. If I add /umbraco behind it to access the dev dashboard I just get a white page.
I have only been working with it for 5 days and am new to umbraco. IIS on the local server here has no web deploy installed and FTP is also not an option. I developped the website with Webmatrix and web deploy & FTP are the only two publish option it gives me.
Is there something I did wrong or how can I get the website to work properly here?
Umbraco needs to run in Full Trust mode. Make sure that your IIS is configured for Full Trust.
On Features View --> .NET Trust Levels --> Full (internal)

Resources