How to provide an .exe file as download on Windows Azure Website? - azure

I am trying to publish a ClickOnce installer onto a website which is hosted on Windows Azure. The publishing process works as expected, nontheless the setup file is not available for download via HTTP. Obviously it is not possible to provide executables (.exe) and libraries (.dll) via HTTP. They are available via FTP, but HTTP requests yield a 'File not found' (404). After renaming the file to setup.txt, it can be downloaded, this doesn't really help, though. Can this be configured somehow?

Please try by adding the following in your web.config file:
<system.webServer>
<handlers>
<add name="Client exe" path="*.exe" verb="*" modules="StaticFileModule" resourceType="File" />
</handlers>
</system.webServer>
Source: http://mike-ward.net/blog/post/00631/how-to-configure-iis-7-to-allow-downloading-exe-files.

Add the allowed mime type to web config. Eg:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".exe" mimeType="application/exe"/>
</staticContent>
</system.webServer>

Related

Azure Web App Virtual Application, The resource you are looking for has been removed, had its name changed, or is temporarily unavailable

I have an Azure Web Application with Virtual Application configured under the Path mappings section. The virtual path /SP2019resources has the Physical Path as site\wwwroot\SP2019resources.
My Azure DevOps pipeline will upload the contents (SharePoint SPPKG files) to this virtual path. And I have already verified that the contents are there, however whenever I formulate a URL as https://{AzureAppName}/SP2019resources/{PackageName}.SP2019.sppkg and open it in the browser the file is not getting downloaded and always getting an error as "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.".
Here is the file view from my web app SCM.
Any idea what I am missing here?
After spending some time with this issue, I understood what I am missing. Essentially, you will need a Web.config file in your virtual application folder to handle the requests.
The content of the file can be as follows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="StaticHandler" verb="*" path="*" type="System.Web.StaticFileHandler" />
</handlers>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
After I add this file to the /SP2019resources, the files inside were getting downloaded.

How to enable URL Rewrite in IIS with a .NET Core website

I have created / maintained .net mvc websites for many years and I am working on my first .net core website. I am using Windows server 2019 with IIS. My goal is to duplicate the rewrite rules I have created for my mvc websites on my new core website (one example is the canonical host name rule). I don't have any problems doing this in IIS for the new core website. My problem is when I publish changes, the web.config file on the server gets overwritten and the rules are removed (because I created them in IIS not in Visual Studio). .net core does not have a web.config file in Visual Studio to modify, but a default version is sent to the server when publishing.
Here is the default version if this helps:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\websitename.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 81d237a0-1b33-43a4-8e2b-eed282153721-->
I resolved this issue by adding the below lines to the project file, which turns off creating/transforming the web.config file when publishing:
<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
My question is if my approach is an appropriate way to implement url rewrites? I am using IIS, so a web.config file is required, but it isn't something I can edit in Visual Studio for core like I could for mvc (at least I am not aware of how to do it).

.NET Core App | IIS | HTTP Error 500 - Could not load configuration. Exception message: Attribute 'processPath' is required

I'm trying to host two applications in IIS in Windows Server 2019, in the same site. One of the applications is a website's front-end, in Angular, and the other one is the website's API, in ASP.NET MVC (.NET Core 2.2.8).
The front-end application's URL is site_url/portal and the API's is site_url/api.
Before using the API's other actions, one has to request a JSON web token from the site_url/api/identity URL, using Windows Authentication.
The front-end seems to be working fine, but trying to reach the site_url/api/identity API in the quality control environment yields "HTTP Error 500.0 - Internal Server Error".
I activated detailed logs in IIS and the error message in Event Viewer was "Could not load configuration. Exception message: Attribute 'processPath' is required."
The API's web.config file does have a process path:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\PortalAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" forwardWindowsAuthToken="true"/>
</system.webServer>
</location>
</configuration>
Aditionally, the IIS error page shows something which I find strange. The request URL is correct, but the physical path is application_path\identity. "Identity" is an MVC controller, not a file.
The .NET Core 2.2 Windows Hosting Bundle is installed and the .NET path environment variable is set.
The application pool identity is an applicational user, and .NET CLR version is set to "No Managed Code".
The site has both Anonymous Authentication (for the front-end login page) and Windows Authentication enabled.
The thing is, I have hosted the applications in the exact same way in both the development environment and a clean Azure virtual machine, and they work in both, which makes me think this has to do with some setting in either IIS or the quality control machine itself.
Does anyone have any idea what the problem and/or possible solutions might be?
A missing configuration caused this error for me until I added it: environment variable ASPNETCORE_ENVIRONMENT
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\PortalAPI.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" >
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
You can put this in web.config, but it will get removed if you publish a new version of the web app from Visual Studio. To avoid that, put it in applicationHost.config instead (in the location corresponding to your site).

.NET Core WebAPI IIS Deploying

I have created a webAPI using .Net Core and trying to publish it to IIS. But getting HTTP 500.19.
It's looking for web.config file but I don't have it.
What should I do?
Did you installed this: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?tabs=aspnetcore2x&view=aspnetcore-3.1
If Yes check your permissions on the folder. The identity under which your web application runs in IIS may has not full access to the folder in which the web.config file is found. You could change your identity under the appPool or grant access to your folder. If you deployed into the wwwroot folder the IUser should have access to the folder.
When you publish your .net core in IIS please remember to install .net core web hosting bundle because it is not supported by default. IIS handle request based on different handlers. Even when you install the extension, aspnet core module is not registered. So please remember to set
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<aspNetCore processPath=".\myapp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
If the solution doesn't fix this. Then something in your web.config is corrupting the application. Please post a screenshot the detailed error message. Then we would know how to fix this completely.

How to install Ghost inside an existing node.js application on Azure?

Can you install Ghost (http://ghost.org) so that it runs inside an existing node.js express application (like this: {my domain}/blog)?
I'm using Azure Websites to host the site.
Please note: I would prefer a generic solution that can run on any platform... however I thought I would mention that it's on Azure in case it provides a simple way to do this.
Yes you can do that.
You will need to:
1. Add a new blog application
Basically go to portal -> CONFIGURE tab -> scroll all the way to the bottom and add something like this
2. Configure Ghost to run on a sub folder
publish Ghost to whichever folder you mapped to your application in the step above.
You can use FTP, webdeploy or SCM (https://<YouSiteName>.scm.azurewebsites.net/DebugConsole
that's what I choose and my folder layout looks like this
igonre the deployments folder, it's not related to this
in your config.js for Ghost, under the Production environment node make sure you have the url as
production: {
url: 'http://<YourSiteName>.azurewebsites.net/blog',
mail: {
......
}
}
3. Fix the main site's web.config
go to your main sites web.config and wrap the whole <system.webServer> element in a <location path="." inheritInChildApplications="false">
basically your web.config should have looked like this
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Some rewrite rules -->
</rules>
</rewrite>
....
</system.webServer>
</configuration>
and now it should look like this
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Some rewrite rules -->
</rules>
</rewrite>
....
</system.webServer>
</location>
</configuration>
notice this is for the main site that is the Express.js in your case not the Ghost site
that should be all you need to do.
Not sure if you can install it as an addition to your existing site, but Ghost exists as a deployable template in the Azure Web Sites gallery, under Blogs:
This is not the complete answer you were looking for, but these instructions on how to manually install Ghost on Azure Websites might help guide you in the right direction:
http://www.hanselman.com/blog/HowToInstallTheNodejsGhostBloggingSoftwareOnAzureWebsites.aspx

Resources