I've created an ASP.NET MVC 4 app using visual studio 2012 RC on Windows 8 release preview. I downloaded and installed the WIF toolkit and used the "Identity and Access" option in the solution menu to add my Access Control Service metadata endpoint. Tested locally and all is well. When I deployed to my free azure website however I get the yellow screen saying


  "Could not load file or assembly 'System.IdentityModel.Services,
  Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
  one of its dependencies. The system cannot find the file specified."


These assemblies aren't referenced in the project, so I added them, sent to output to the bin folder and redeployed. I then got a message about the assembly probably being tampered with. Does anyone know how to overcome this?

EDIT
Adding local causes this error


  Could not load file or assembly 'System.IdentityModel.Services' or one
  of its dependencies. Strong name signature could not be verified.  The
  assembly may have been tampered with, or it was delay signed but not
  fully signed with the correct private key. (Exception from HRESULT:
  0x80131045)


In the web config the module is deinfed as

&lt;system.webServer&gt;
    &lt;validation validateIntegratedModeConfiguration="false" /&gt;
    &lt;modules&gt;
      &lt;add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" /&gt;
      &lt;add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" /&gt;
    &lt;/modules&gt;
  &lt;/system.webServer&gt;


Thanks


Question: Calculating pH of diprotic and amphoteric solutions
Answer: I'll address your questions in 3 parts: 

(A) Why amphoteric

(B) How to solve the problem without making unexplained assumptions

(C) Why the solution in the book uses the approximate equality
    $\ce{[H3AsO4]=[HAsO4^{2-}]}$.

PART (A)

An amphoteric species (molecule or ion) is one that can either gain a proton with relative ease, or lose a proton with relative ease. "Relative ease" means, for example, that it can happen in aqueous solution. If your species will gain a proton in the presence of enough $\ce{H3O+}$, and if it will lose a proton in the present of enough $\ce{OH-}$, it can certainly be called amphoteric.

Translated into equilibrium constants, if your species has a pKa between 0 and 14, and its conjugate acid (what you get when you protonate it) also has a (necessarily lower) $pK_a$ between 0 and 14, your species will act in aqueous solution as either as an acid (losing a proton in the presence of strong base) or as a base (gaining a proton in the presence of strong acid).

The $pK_a$ of (neutral) arsenic acid is between 2 and 3 (because the equilibrium constant for removing the first proton, $K_1$, is between $10^{-2}$ and $10^{-3}$). The $pK_a$ of the version that lost one proton, $\ce{H2AsO4-}$, is around 7 (from the value of $K_2$). So clearly $\ce{H2AsO4-}$ will gain a proton if the pH is below 1, say, and it will lose a proton if the pH is above 10. This justifies why it's amphoteric.

PART (B)

In a monoprotic acid like HF, all the F appears either as F$^-$ or as HF (two species). You can write down 1 equilibrium equation, a mass balance for F and a charge balance, and solve all three equations simultaneously; when you combine the three you get a quadratic equation that can be solved exactly.

But with a multiprotic acid, things get complicated fast. In this problem you have three equilibrium equations, plus the mass-balance and charge-balance equations.  That's 5 equations in 5 variables.

Fortunately it's possible to combine 4 of them easily, using only high-school algebra. They are the 3 equilibrium equations and the charge balance. This reduces the problem to two variables (the pH and the concentration of one of the arsenic ions) in two equations.

Let's write and combine the 4 equations. There are four arsenic species with varying charges; I'll call their concentrations $A_0,A_1,A_2,A_3$ -- the index denotes the charge (which is 3 minus the number of hydrogens). So $A_0=[\ce{H3AsO4}]$, $A_1=[\ce{H2AsO4-}]$, and so on.

By definition, $A_1[\ce{H^+}]/A_0=K_1$, or equivalently $A_0=A_1[\ce{H^+}]/K_1$. This relates two concentrations, $A_0$ and $A_1$. Similarly $A_1=A_2[\ce{H^+}]/K_2$ and $A_2=A_3[\ce{H^+}]/K_3$.

The important thing is that all these four concentrations are proportional and given one you can find all others if you know the pH. (We don't know the pH, but I'll address that in a moment.)

The charge balance (expressed in moles present in 1 L of solution) is simply 
\begin{equation} 0\,A_0+ 1\,A_1+ 2\,A_2+ 3\,A_3+K_w/[\ce{H^+}]= [\ce{H^+}]+0.1. 
\end{equation}
On the left we have the negative charges, on the right the positive ones. Notes:


The concentration of each arsenic species is multiplied by its charge, obviously.
On the left side, $K_w=10^{-14}$ is the dissociation product of water, and $K_w/[\ce{H^+}]$ represents the concentration of OH$^-$; it will turn out to be negligible, but we don't know that a priori, and including it doesn't make the problem any harder.
The 0.1 on the right comes from Na$^+$ ions; being an alkali metal, sodium does not exist in water solution except in ionic form, so we know [Na$^+$] exactly. This explains something that will be important later: The 0.10 M solution of $\ce{NaH2AsO4}$ is exactly what you obtain by dissolving 0.10 moles of NaOH in one beaker, 0.10 moles of $\ce{H3AsO4}$ in another, and mixing the two, assuming the combined volume is 1 L.


Now we express the left side of (1) in terms of just two
concentrations, $A_3$ and $\ce{[H^+]}$: $$
\begin{aligned}A_1+2\,A_2+3\,A_3&amp;=(\ce{[H^+]}/K_1)\,A_2+2\,A_2+3\,A_3\\
&amp;=(\ce{[H^+]}/K_1+2)\,A_2+3\,A_3\\
&amp;=(\ce{[H^+]}/K_1+2)(\ce{[H^+]}/K_2)\,A_3+3\,A_3\\
&amp;= \bigl((\ce{[H^+]}/K_1+2)(\ce{[H^+]}/K_2)+3\bigr)\,A_3
. \end{aligned} $$

The last line is the key; it allows us to relate the concentration of one arsenic
species to the pH.  With this (and moving the $K_w/\ce{[H+]}$ to the
right)
the charge balance becomes
$$ \bigl((\ce{[H^+]}/K_1+2)(\ce{[H^+]}/K_2)+3\bigr)\,A_3
=\ce{[H^+]}+0.1 -K_w/\ce{[H+]}$$
or again
$$ A_3=
=\frac{\ce{[H^+]}+0.1 -K_w/\ce{[H+]}}{\bigl((\ce{[H^+]}/K_1+2)(\ce{[H^+]}/K_2)+3\bigr).}$$

This look complicated, but it's easy to put into a spreadsheet. The last step is this: The right [H$^+$] is the one that, with $A_3$ calculated as above, obeys the mass balance, $$ A_3 + A_2 + A_1 + A_0 =0.1.$$

At this point we could declare the multiple-choice problem solved, by cheating a bit: take the various proposed values of  [H$^+$] and see which one works.  For answer (a) the value of the sum $ A_3 + A_2 + A_1 + A_0$ is 0.62; for (b) it is  0.128; for (c) it is 0.10165, and for (d) it is 0.100002.  So the best answer is (d).

What if you didn't have multiple choice? Then you'd want to draw a graph or a table, taking (say) every integer value of pH and connecting them.  Here is such a graph: 



The horizontal axis is pH and the vertical one is total arsenic concentration.  The correct pH is where the vertical coordinate is exactly 0.1, and you can get a good idea of its value by eyeballing, or solve by successive approximations.

Note that this method allows you to solve with no more effort the following problem: what is the pH when you add 0.1 mol/L of $\ce{NaH2AsO4}$ (as in the original problem), plus 0.05 mol/L of $\ce{H3AsO4}$?  The only difference is that now you'll be looking for the point on the graph where the vertical coordinate is 0.1+0.05 = 0.15, instead of 0.1.

PART (C)

Why does the book say that $\ce{[H3AsO4]=[HAsO4^{2-}]}$, approximately? And is this a good approximation?

The equality comes from the claim that the "dominant reactivity" of $\ce{[H2AsO4-]}$ is $$\ce{2\,H2AsO4- \leftrightharpoons H3AsO4{}+HAsO4^{2-}}.$$ If $\ce{H2AsO4-}$ exchanges protons only with itself, and not with, say, water, then every proton lost by one $\ce{H2AsO4-}$ ion means a proton gained by another $\ce{H2AsO4-}$, and the result is that $\ce{[H3AsO4]}$ and $\ce{[HAsO4^{2-}]}$ are generated in equal amounts.

So given the claim about "dominant reactivity", the equality is true, and by the way, the equality implies that the pH is the average of $pK_1$ and $pK_2$. (This follows, by taking logs, from the analysis that I'm guessing your book gives right after the part of the solution you quoted.)

The problem with the claim is that it does not follow from the amphoteric nature of $\ce{H2AsO4^-}$ alone. It requires two additional conditions: You're starting from only $\ce{H2AsO4-}$, and in relatively high concentrations. I'll illustrate why these conditions are necessary:

(1) You have to start with only $\ce{H2AsO4-}$ (plus a counterion that doesn't participate further, like Na$^+$). If you started with some $\ce{H3AsO4}$ in addition, you wouldn't have the equality $\ce{[H3AsO4]=[HAsO4^{2-}]}$, even approximately. Or, to use the example you gave, if you start with H$_2$S the amphoteric character of HS$^-$ wont help you calculate the pH of the resulting mix. On the other hand if you started by dissolving NaHS alone, it would.

(2) You have to start with a strong solution. If the original question had specified a 0.1 mM solution instead of a 0.1 M solution, the resulting H$^+$ concentration would not be $2.5\times 10^{-5}$ anymore but $3.3\times 10^{-6}$, and the equality $\ce{[H3AsO4]=[HAsO4^{2-}]}$ would be off by a factor of 60!

I hope this helps answer your very interesting and perceptive questions.  Don't hesitate to ask for further clarification if necessary!