我正在使用ASP.Net MVC 4 RC的ApiController,我正在尝试对GET方法进行单元测试.
这个方法使用的CreateResponse<T>方法HttpRequestMessage,但我不知道如何模拟它或使其正常运行.
该方法的主体包含:
MediaTypeHeaderValue header = new MediaTypeHeaderValue(versionedSmartBlock.ContentType);
var response = Request.CreateResponse<SmartBlock>(
HttpStatusCode.OK, versionedSmartBlock, header);
Run Code Online (Sandbox Code Playgroud)
在我的单元测试中,我创建一个空的HttpRequestMessage:
CallsController api = new CallsController(
managerMock.Object, config, adapterFactoryMock.Object);
api.Request = new HttpRequestMessage(
HttpMethod.Get, "http://localhost/Initiate?ern=%2B44123456789");
var response = api.Get("+44123456789", null);
Run Code Online (Sandbox Code Playgroud)
但它只会产生一个InvalidOperationException:
请求没有关联的配置对象,或者提供的配置为null.
有没有人有关于我如何配置的任何指示,HttpRequestMessage以便该CreateResponse方法实际上发挥作用?
我正在使用XIP.IO通配符域来访问在本地IIS服务器上运行的网站.
今天,IE 11停止访问该网站,而Chrome和Firefox继续访问该网站.它甚至适用于远程机器,所以我知道它与我的本地IE有关.
我检查了没有代理设置,重置IIS,重置IE 11,事件重新安装IE 11 - 一切都无济于事.我在Windows 8.1预览版上运行.
这已经有好几个月没有问题.我甚至想不到我最近安装的任何会导致此问题的软件.
作为一个兴趣点,当我启动Fiddler时,IE报告"代理没有响应".它几乎就像无法解析本地IP地址或其他东西.
任何指针将不胜感激!

我正在尝试为正在开发的新tent.io协议创建一个客户端,他们正在使用http://tools.ietf.org/html/draft-ietf-oauth-v2-http所描述的HTTP MAC Oauth2方案.-mac-01.
我在C#中编写了一个创建Authorization标头的简单方法,但是当我提交请求时,我得到一个简单的"无效MAC签名"错误.
由于我没有参考实现,我正在努力弄清楚我的代码有什么问题.我在这里发帖,希望有人能发现我的错误.
public string GetAuthorizationHeader(string macKeyIdentifier, string macKey, string macAlgorithm, string method, Uri uri)
{
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
string timestamp = ((int)t.TotalSeconds).ToString();
string nonce = new Random().Next().ToString();
string normalizedString = string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n\n",
timestamp,
nonce,
method,
uri.PathAndQuery,
uri.Host,
uri.Port);
HashAlgorithm hashGenerator = null;
if (macAlgorithm == "hmac-sha-256")
{
hashGenerator = new HMACSHA256(Encoding.ASCII.GetBytes(macKey));
}
else if (macAlgorithm == "hmac-sha-1")
{
hashGenerator = new HMACSHA1(Encoding.ASCII.GetBytes(macKey));
}
else
{
throw new InvalidOperationException("Unsupported …Run Code Online (Sandbox Code Playgroud)