Deploying from WebMatrix for AppHarbor - deployment

I am trying to deploy to AppHarbor a website. Of course, i had to disable precompilation and other stuff, but appharbor builds it fine and deploys it to http://nitelists.apphb.com/.
However if you enter, you see a forbiden acess error, don't know why.
(note that i am using the SQL lite database that comes integrated with WebMatrix)
Do i have to change something of the web.config file to make it work? This are the actual file contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration >
</configuration>

My web.config file looks like this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>

Related

IIS 10 - web.config - how to enable default document without script access

We have a folder which contains only static html and images etc. No scripts should be allowed to execute from within this folder. However we would still like to be able to use html default documents.
What is the correct way to configure this?
This is the web.config file...
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read"/>
<defaultDocument enabled="true">
<files>
<clear />
<add value="default.html" />
<add value="default.htm" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
If I attempt to access http://mysite/mystaticfolder/ it fails with the error...
HTTP Error 403.1 - Forbidden
However the URL http://mysite/mystaticfolder/default.html works fine.
Surely it shouldn't be nescessary to allow dynamic scripts, just to be able to serve static html default documents?
In case it helps anyone, I've been able to solve it with the following...
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read">
<clear/>
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule" resourceType="Either" requireAccess="Read" />
</handlers>
<defaultDocument enabled="true">
<files>
<clear />
<add value="default.html" />
<add value="default.htm" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
I'm not entirely sure though why this doesn't work by default though.

Blazor - how to use brotli compression

Blazor WASM supports gzip/brotli compression. Official documentation shows example web.config
however this web.config is not using hosted model.
If I merge example web.config with root web.config
<?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=".\app.Server.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Javascript files, css, images becomes unreachable. I also tried put example web.config into wwwroot/_framework folder, however no change at all.

NuGet Package transform a config transform file

Is there a way to make a NuGet package transform a config transform file? For example, when I want my NuGet package to edit a web.config file, I create a web.config.install.xdt file. But what if I want my NuGet package to edit a web.config.debug file?
I tried making a web.config.debug.install.xdt file, but ran into one issue: I cannnot get the transformation to insert attributes that are themselves attributes of xdt transformation. Something like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt1="http://schemas.microsoft.com/XML-Document-Transform">
<system.serviceModel >
<client xdt1:Transform="Insert">
<endpoint address="http://blah.blah" binding="basicHttpBinding" contract="Test.Contract"
name="TestWs" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</client>
</system.serviceModel>
</configuration>
(I tried changing the namespace of xdt, but that didn't help either.)
Although this isn't perhaps the best answer, it did get the job done for me when I found myself in this situation:
Use the "old" method of doing transforms, not the xdt way.
https://docs.nuget.org/create/Transforming-Configuration-Files-Using-dotTransform-Files.md
This seems to work well, just make sure the appropriate xmlns attribute is in the .transform file.
For example, if you wanted to transform your web.qa.config file that currently looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="Tier" value="qa" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
</configuration>
You could add an element:
<add key="RedirectUri" value="yourRedirectUriForQA" xdt:Transform="Replace" />
By adding the following web.qa.config.transform file to your Nuget package:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="RedirectUri" value="yourRedirectUriForQA" xdt:Transform="Replace" />
</appSettings>
</configuration>
Just make sure also to add it to the .nuspec file so it gets picked up when packaged.

Build folder stays empty

Hi Im trying to follow the tutorial here regarding Struts. I have followed the tutorial exactly but am getting an HTTP 404 error. I know this error basically means that the resource can't be found be the the IDE.
I noticed that the 'Build' folder is actually completely empty - so I'm guessing that it should have automatically created a runnable project based on my project specifics and this is actually where the server looks in order to run an application.
So how do I go about manually generating this file? Should I drag all the resources in? Java classes, JSP files and so? If not how do I configure it to automatically build?
Cheers
EDIT
Have added what I think will be necessary to help solve this:
Web.xml Located in the WEB-INF folder, next to lib
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts2 Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
Struts.xml Located in a src folder called resources in the Java Resources folder
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<!--
If we changed from the default execute() method, which struts looks for
to say authenticate(), then we would have to specify this in the action
method below like this:
<action
name="login"
method="authenticate"
class="net.viralpatel.struts2.LoginAction">
</action>
-->
<action name="login" class="net.viralpatel.struts2.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
</package>

How do you set a relative path for a file-based package source with NuGet?

I'm using NuGet 2.1 with multiple solutions, each in a child directory under a single parent directory and a single packages directory which is shared by all the solutions (this became possible with NuGet 2.1).
I'd like to add a file-based package source which points to the packages directory in my working copy (I'm using Subversion).
This works:
<configuration>
<repositoryPath>_Packages</repositoryPath>
<activePackageSource>
<add key="Working copy package source" value="C:\AllMySolutions\_Packages" />
</activePackageSource>
</configuration>
This doesn't:
<configuration>
<repositoryPath>_Packages</repositoryPath>
<activePackageSource>
<add key="Working copy package source" value="_Packages" />
</activePackageSource>
</configuration>
I don't want to hard-code the absolute path but can't find a way of using a relative path in the value attribute inside activePackageSource.
It looks like this is now supported.
http://nuget.codeplex.com/workitem/2810
Put a file called nuget.config in the root of your solution (next to packages folder and solution file) containing:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Local" value="packages-local" />
</packageSources>
</configuration>
Build you packages to the packages-local folder.
The packages in this folder will be available to add to other projects in the solution. (You may need to restart VS or at least close-reopen your solution for the config to be picked up).
I had same problem with <repositoryPath>. I needed to force all SOLUTIONs in my git repository to use same folder to store their NuGet packages. So I created a nuget.config file on the root of the repository with the following contents, as it was described in documentations:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="NugetPackages\" />
</config>
</configuration>
After manually creating NugetPackages beside nuget.config and installing packages, there was nothing in that directory, but everything was working fine. Then I found that VS has created C:\NugetPackages and moved packages there. After trial and error for a while, at last the relative path using .\ worked for me:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value=".\NugetPackages\" />
</config>
</configuration>
I hope it behaves the same for other configurations as well.
P.S.: As Matthew already said, I had to restart VS to make my edits in nuget.config take effect.
For .NETCore/.NET5 and newer, the config key repositoryPath doesn't work anymore, and it is now named globalPackagesFolder, so:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value=".\packages\" />
</config>
</configuration>