2014-06-07 87 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控制檯問題。