0
我有一個webAPI服務圖像。img標籤消費認證的webapi
http://{uri}/Data/api/v1/ImageData?objectType=1&dbKey=12
我試圖使用它在<img>
標籤動態地在C#這樣的:
var src = string.Format("http://{uri}/Data/api/v1/ImageData?objectType={0}&dbKey={1}", viewType, dbKey);
html.Append(@"<div class='Image'>");
html.AppendFormat(@"<span><img src ='{0}'/></span>", src);
html.Append(@"</div>");
現在,我碰到的問題是,我的WebAPI有我需要傳遞一個基本的身份驗證用戶名和密碼。我怎樣才能做到這一點?不像this問題,我試圖找到更好的方法來傳遞用戶名和密碼。
可能的重複[如何設置標記與基本身份驗證](http://stackoverflow.com/questions/3823357/how-to-set-the-img-tag-with-basic-authentication) – FrankerZ