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

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.

Related

How to setup iis in Azure web app service with Net Core 2 app?

I develop simple Web Api on Net Core 2 and add Angular app to it (inside wwwroot folder) and publish it from my VS 2017 IDE to Azure Web App Service. All work fine, but when I reload page of my app in browser, server can't find route. So It often happens when iis not setup for SPA, It's described in https://angular.io/guide/deployment, I must configure the server to return the application's host page (index.html) when asked for a file that it does not have. How I can setup server node of iis in Azure Web App Service (web.config in Net Core 2 was deleted).
I am afraid you cannot achieve this.
Cause: Azure App Services runs IIS so it behaves mostly the same as local IIS, routing requests using a native module called AspNetCoreModule. So, it needs your published web.config file. Even though you deleted the web.config file, Azure would also generate a new web.config file to be used.(Though I don't understand why you delete the web.config file)
Solution:
Even you can upload the web.config file to Azure again, I'm afraid of that it will be ignored and doesn't work. So, I suggest you redeploy your website which contains web.config file to Azure and configure it well.
Additional: Azure Web App service is a kind of PaaS. So, if you want to install IIS manually, you can choose to host your website on a Windows Azure VM.

Getting error when trying to call API inside Web App through another Web App - Azure

I have two Web Apps, inside the same App Service. One is a back-end portion (with API on it, using .NET Core, SSL cert installed) and the other one is the front-end (ReactTS, created using create-react-app).
When I try to call the API method (an Auth method) using my Front-end I got this message as response:
Login failed: The resource you are looking for has been removed, had
its name changed, or is temporarily unavailable.
-404 error
Another fact is, if I run my ront-end solution locally, I can use the API (published on the Web App), normally.
My API URL is set inside the package.json file, as proxy.
My first thought was about an CORS problem, but it throws a 404 error.
Any configuration that I can do on my Azure, or something that I need to change in my application to allow my front-end to communicate with my API?
If we publish two web applications to one Azure Web App, the later one will cover the first one. It will cause that the first web application can't work. I suggest you create different Azure Web Apps for your web applications. You could choose one Azure Web App Plan for your Azure Web Apps. It will not add extra costs except for Shared plan.
If you use Shared App Plan and don't want to increase the extra cost, you could add a virtual directory to your Azure Web App. Then you could publish your second web application to the virtual directory. To create a virtual directory, steps below are for your reference.
Azure portal -> Web App Panel -> Application settings

IIS 7.5 + MVC 5 + NInject + PostSharp - Suddenly 401 on remote machine

I have a web application developed in VS2013
ASP.NET MVC 5
NInject for IoC
Sql Server 2008 R2 for a backing store (ADO, not Entity Framework, for DAL)
IIS 7.5 (Not a web garden, max processes = 1)
PostSharp 3.1.46.0
I have been developing and deploying on my local machine this application to a development server for months with not too many issues.
App Pool is .Net 4.0 Integrated, using the ApplicationPoolIdentity
Anonymous and Forms authentication are enabled. Anonymous is set to use the App Pool identity
File permissions are set for the application folder to give IIS AppPool\[mypool] read, list, execute access. (I tried full access, once, and it didn't help)
Last week, the development server reports a 401 (sc-status:401 sc-substatus:0 sc-win32-status:0) instead of showing me any forms from a remote connection. Local connections, that is, when I access the app on the sandbox, or if I log on to the development server and access it locally, work as expected. Any request from a remote machine fails.
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 tried recreating the app pool and re-assigning the app to it. I tried aspnet_iisreg -ir. I went through most of the "Similar Questions" to the right of this edit box, trying to find something close to my issue. I erased the application from the server and redeployed to a new app, with new name and a new physical folder. KB2545850 hotfix didn't help.
My deployment strategy is an xcopy of everything but the web.config(s) I maintain the web.config separately. Please help diagnose.
In ASP.NET MVC Deploying an app with forms authentication to IIS 7.5 it says:
If you have a path leading to an eventual [Authorize] attribute, that will cause this -
removing the RenderAction or allowing that action to render without [Authorize] fixes it.
That was similar to my issue. I have a global filter to Authorize. I recently added a partial view in a controller to display a serial number. I added that partial to the _Layout, without the AllowAnonymous. Since the login form used the layout, which used this partial, I couldn't log in until I logged in.
Adding an [AllowAnonymous] to the action resolved this issue. I am thinking about how to more easily detect this for when it happens to me again.

Web API on Azure errors until App Pool is Recycled

I have a web role that hosts 4 MVC 4 sites. One of the sites (let's call it the API site from now on) uses both MVC and Web API. When I upgrade the web role, the Web API controllers from the API Site returns a 500 Internal Server Error to all requests. The MVC controllers work as expected and I know the request is getting at least as far as the Application_BeginRequest method of the global.asax. I'm not seeing anything logged in my Elmah log. The only hint I have of anything being wrong is the following in the event log:
The application '/' belonging to site '1' has an invalid AppPoolId 'DefaultAppPool' set. Therefore, the application will be ignored.
As web roles use App Pools with guids as identifiers I don't know where this is coming from.
What is most confusing is that once I recycle the app pool for the API site (which is a guid) everything starts working correctly.
I've tried recyling the app pools as part of a startup task on the role, but that doesn't seem to make any difference.
Any suggestions about what I can do to get Web API to start correctly?
I never did find what was causing this issue.
It got to a point where I could deploy from my machine and not get the problem, but my colleague could not.
We tried comparing the contents of the .cspkg files that were produced, but didn't find any differences.
We are now both able to deploy the project with no problems.
My suspicion is that this was resolved when we upgraded the Azure SDK and tools on our machines.

Connection was reset / file upload in asp.net azure with ssl only

I am trying to upload a file to blob in asp.net azure. I am getting success if the page is without ssl. but if i upload with https page then i am getting connection was reset error.
And also I mentioned the maxrequestlength in web.config.
This is not Azure specific error instead it is an ASP.NET specific problem. I did some test if I could hit the problem but no luck..
I am getting sure that the problem is introduced by adding maxrequestlength and potentially having request filtering. You must setup the timeout setting with length and support script runtime in webserver specific settings.
You also have one option to RDP to your instance and enable IIS debugging to understand what could be the problem:
http://www.microsoft.com/en-us/download/details.aspx?id=26798
After running Debug Diagnostic Tool v1.2, please share your log, and i will look for root cause.
To RDP Access to Windows Azure Application, visit my blog here

Resources