2014-06-07 69 views
0

我有一个简单的测试Web API已启动并正在运行。当我运行它并在浏览器中输入http://localhost:xxxxx/api/user时,它将返回一个JSON空数组,当我使用Fiddler对其进行测试时,它具有完整的功能。但是,当我尝试使用Chrome REST控制台(GET请求至http://localhost:xxxxx/api/user)进行测试时,出现“连接失败!请检查您的连接并重试”错误。Chrome REST控制台“连接失败!”

阿比控制器:

public class UserController : ApiController 
{  
    private UserRepository repository = new UserRepository(); 

    public int Put(int id, [FromBody]int amount) 
    { 
    var user = repository.GetByID(id); 
    if (user == null) return -1; 
    user.Total += amount; 
    repository.Save(user); 
    return user.Total; 
    } 

    public int Post([FromBody]CreateUserRequest request) 
    { 
    var user = new User { Goal = request.Goal, Name = request.Name, Total = 0 }; 
    repository.Add(user); 
    return user.UserId; 
    } 

    public IEnumerable<User> Get() { return new List<User>(repository.GetAll()); } 

    public User Get(int id) { var user = repository.GetByID(id); return user; } 

    public class CreateUserRequest 
    { 
    public string Name { get; set; } 
    public int Goal { get; set; } 
    } 

其余控制台以前曾用这个测试的Web API的工作。我可以在Web上找到的唯一参考引用了未签名证书。我在IIS中为localhost创建了一个签名证书,但是我删除了它,重新启动了计算机,并且REST控制台仍然返回相同的错误。这并不重要,因为Web API在IIS Express中运行。我也在本地机器上用其他Web API进行了尝试,并得到相同的错误。

有没有人有任何想法可能的问题来源或如何我可能会排除故障?正如我所说的,当使用Fiddler进行测试时,Web API是完全可用的。 Web API是使用Windows 7 Ultimate工作站上的VS 2012创建并正在运行的。

回答

0

我后来注意到,当我在Chrome中从Visual Studio运行应用程序时,它会重定向到https(即使对于不使用SSL的应用程序)并生成SSL错误。

我清除了Chrome中的所有浏览数据,并清除了Chrome和REST控制台问题。