By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

The request failed with HTTP status 401: Unauthorized.

P: 1
Hi,

I am using XP PRo, .NET 2003 and IIS. I am getting a 401 and I 100% my authentication should be fine. Any thoughts?

code========================

using System;
using System.Drawing;
using System.IO;
using System.Web;
using BREWServer.MapPointService;
using System.Collections.Specialized;
using System.Web.UI.HtmlControls;

namespace BREWServer
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{

RenderServiceSoap renderService = new RenderServiceSoap();
renderService.PreAuthenticate = true;
renderService.Credentials = new System.Net.NetworkCredential("*******","********** *");

ViewByScale[] myViews = new ViewByScale[1];
myViews[0] = new ViewByScale();
myViews[0].CenterPoint = new LatLong();
NameValueCollection coll=Request.QueryString;

String latlon = coll.GetValues("latlon")[0];
int sep = latlon.LastIndexOf("^");
String lat = latlon.Substring(0, sep);
String lon = latlon.Substring(sep + 1, latlon.Length - (sep + 1));

myViews[0].CenterPoint.Latitude = Double.Parse(lat) / 3106;
myViews[0].CenterPoint.Longitude = Double.Parse(lon) / -3106;
myViews[0].MapScale = 100000;
MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = myViews;

MapImage[] mapImages;
mapImages = renderService.GetMap(mapSpec);

Context.Response.Clear();
Context.Response.Cache.SetCacheability(HttpCacheab ility.NoCache);
Context.Response.ContentType = mapImages[0].MimeData.MimeType;

MemoryStream ms = new MemoryStream(mapImages[0].MimeData.Bits);
Image i = Image.FromStream(ms);
i.Save("c:\\brew\\btmp.png", System.Drawing.Imaging.ImageFormat.Png);
FileStream fs = new FileStream("c:\\brew\\btmp.png", FileMode.Open);
byte[] b = new byte[fs.Length];
fs.Read(b, 0, b.Length);
Context.Response.BinaryWrite(b);

fs.Close();
File.Delete("c:\\brew\\btmp.png");
Context.Response.End();

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
Apr 24 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.