devatwork / premotion-aspnet-appharbor-integration Goto Github PK
View Code? Open in Web Editor NEWProvides seamless integration with AppHarbor by undoing some of the AppHarbor specific behavior.
License: MIT License
Provides seamless integration with AppHarbor by undoing some of the AppHarbor specific behavior.
License: MIT License
Add an app setting which enables this module only when the application is deployed to the AppHarbor servers.
As per this discussion on SO:
It would seem by overwriting the native Init() method, certain helper flags aren't set. One of those certainly appears to be for IsAjax Request. I'm not sure what others could be getting masked, but it's something to be aware of when using the library.
Might be worth comparing to the native method from the MVC.
Also - by only having the library work when on AppHarbor, it makes debugging quite confusing. Is there a real reason to have that as a condition?
I noticed that the code looks to see if the commit id is filled out. However nowhere does the config.transform do this for me.
It would be nice to put that in the readme
Currently there is an hardcoded reference to System.Web.HttpServerVarsCollection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. This wont work with other framework versions.
You should remove the AppHarbor IP from the X-Forwarded-For header so that it properly reflects the incoming request.
Otherwise, the physical outward-facing IP address shows up twice - in the remote address and in XFF.
if (forwardSeparatorIndex < 0) {
serverVariables.Set("REMOTE_ADDR", forwardedFor);
serverVariables.Remove(ForwardedForHeaderName);
} else {
serverVariables.Set("REMOTE_ADDR", forwardedFor.Remove(forwardSeparatorIndex));
serverVariables.Set(ForwardedForHeaderName, forwardedFor.Substring(forwardSeparatorIndex + ForwardedForAddressesSeparator.Length));
}
I'm occasionally getting this exception in my AppHarbor site:
[InvalidOperationException: The behavior of the AppHarbor loadbalancer changed, it no longer specifies the HTTP_X_FORWARDED_FOR header]
at Premotion.AspNet.AppHarbor.Integration.AppHarborModule.<>c__DisplayClass1.b__0(Object sender, EventArgs args) in C:\inetpub\wwwroot\PremotionAspNetAppHarborIntegration\src\Premotion.AspNet.AppHarbor.Integration\AppHarborIntegrationModule.cs:line 89
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
You should be aware that X-Forwarded-For may be a comma separated list if also provided by the client.
Since we inject a key called "appharbor.commit_id", you could use that instead of a custom variable to simplify it even further. Suggested by Troels Thomson.
I get the following error when loading my login page:
System.NotSupportedException: Collection is read-only.
at System.Collections.Specialized.NameObjectCollectionBase.BaseSet(String name, Object value)
at System.Web.HttpServerVarsCollection.SetServerVariableManagedOnly(String name, String value)
at System.Web.HttpServerVarsCollection.SetNoDemand(String name, String value)
at System.Web.HttpRequest.SetSkipAuthorization(Boolean value)
at System.Web.HttpContext.SetSkipAuthorizationNoDemand(Boolean value, Boolean managedOnly)
at System.Web.Security.FormsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The problem is that you make the ServerVariables collection read-only even if it didn't used to be.
I broke out the source and fixed it myself (and greatly simplified the code) at https://gist.github.com/2025391
Sorry for the non-pull-request; I was in a hurry
It appears I am losing headers now that I am using this...
X-NuGet-ApiKey: thekey <- I replaced the actual guid with thekey in this issue report only. The actual request makes use of a real key.
PUT http://chocotest.apphb.com/api/v2/package/ HTTP/1.0
User-Agent: NuGet Command Line/1.6.21205.9031 (Microsoft Windows NT 6.1.7601 Service Pack 1)
X-NuGet-ApiKey: thekey
Content-Type: multipart/form-data; boundary=---------------------------8cf71b7537342b2
Host: chocotest.apphb.com
Content-Length: 3723
I left out the rest of the request
HTTP/1.1 400 The API key '' is invalid. <- It looks like it is losing the key that is passed to it in the headers
HTTP/1.1 400 The API key '' is invalid.
Server: nginx
Date: Sat, 06 Oct 2012 13:54:58 GMT
Content-Type: text/html
Connection: close
Cache-Control: private
Content-Length: 11
Bad Request
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.