http://pub:123@myipaddress/axis-cgi/jpg/image.cgi?resolution=4CIF
当我使用url地址时,它在chrome,firefox和IE 9中显示不同
1)chrome可以给我一张图片和显示。
2)firefox首先向我显示一个检查对话框,当你点击确定时,它可以给我正确的图片。3)IE 9,它显示我'Windows找不到....'对话框
有没有办法像Chrome浏览器那样访问相机服务器。
我想使用asp.net来请求摄像头服务器,在使用http://myipaddress/axis-cgi/jpg/image.cgi?resolution=4CIF
时,它会显示用户名和密码的Windows Security
对话框。
我希望在c#代码中发送用户名和密码,我不想看到“Windows安全”对话框,但我不想在摄像机服务器的用户中设置Enable anonymous viewer login
设置。
有什么办法可以解决吗?
答案 0 :(得分:0)
您需要获取用户名和密码并将其嵌入对象
<html>
<head>
<title>H.264 Live View</title>
</head>
<body>
<div align="center"><h2>H.264 Live View</h2>
<form name="test">
<input id="ip" type="input" size="10" value="0.0.0.0">
<input type="button" name="Play" value="Play" onClick="OnPlay(); return false;">
</form>
<object id="Player" height="480" width="640" border="1"
classid="CLSID:745395C8-D0E1-4227-8586-624CA9A10A8D">
<param name="AutoStart" value="1">
<param name="UIMode" value="none">
<param name="MediaType" value="h264">
<param name="NetworkTimeout" value="5000"><!-- use this param if you want to change the network timeout -->
<param name="MediaUsername" value=""><!-- this param only necessary if restricted access is enabled -->
<param name="MediaPassword" value=""><!-- this param only necessary if restricted access is enabled -->
<param name="MediaURL" value="axrtpu://myServer/axis-media/media.amp?videocodec=h264"><!-- your media url goes here -->
</object>
</div>
<script language="JavaScript">
<!--
document.Player.EnableContextMenu = true;
document.Player.StretchToFit = true;
document.Player.MaintainAspectRatio = true;
//-->
</script>
<script language="JavaScript">
<!--
function OnPlay()
{
try
{
var server = document.getElementById('ip').value;
// return values from AMC methods are handled as exceptions in JavaScript
document.Player.Stop();
document.Player.MediaURL = "axrtsphttp://" + server + "/axis-media/media.amp?videocodec=h264";
document.Player.Play();
}
catch(e){}
}
//-->
</script>
<script language="JavaScript" for="Player" event="OnError(theError, theMsg)">
<!--
alert(theError + ' ' + theMsg);
//-->
</script>
</body>
</html>
答案 1 :(得分:0)
WebClient client = new WebClient();
client.Credentials = new NetworkCredential(username, password);
byte[] result = client.DownloadData(url);
在C#.net中,我们可以使用WebClient Credentials Property发送用户名和密码