I can't view output from C# web form !??

watchesbMike

New Member
I can't view output from this page on web page. I have created C# web project, and .aspx web form. Then created the following code and when I try to view the page with browser, I see nothing. Can someone tell what I need to do ?<BR><BR><BR><% @Import Namespace="System.Drawing" %><BR><% @Import Namespace="System.Drawing.Imaging" %><BR><script language="c#" runat="server"><BR> void Serpinski(int width, int height, int iterations)<BR> {<BR> ........<BR> ........<BR> }<BR>void Page_Load(Object senter, EventArgs e)<BR> {<BR> Serpinski(200,200, 10000);<BR> }<BR></script><BR>It looks like you are doing my Serpinski Triangle example! Neat! :-) Since you are (I'm assuming) outputting an image, you should set the ContentType property to "image/gif" (or "image/jpg"):<BR><BR>Response.ContentType = "image/jpg"<BR><BR>Also, I'm sure you are outputting the string to the Response's Output Stream? If not, that would be why you're seeing nothing! :-)I have copied your Serpinski Triangle as it is in the article.<BR>Still I do not see anything in the output. Iam not sure if some default setting got overwritten. <BR><BR><%@ Page language="c#" %><% @Import Namespace="System.Drawing" %><% @Import Namespace="System.Drawing.Imaging" %><script language="c#" runat="server"><BR> void Serpinski(int width, int height, int iterations)<BR> {<BR> // create the Bitmap<BR> Bitmap bitmap = new Bitmap(width, height);<BR><BR> // Create our triangle's three Points<BR> Point top = new Point(width / 2, 0),<BR> bottomLeft = new Point(0,height),<BR> bottomRight = new Point(width, height);<BR><BR> // Now, choose our starting point<BR> Point current = new Point(width / 2, height / 2);<BR><BR> // Iterate iterations times<BR> Random rnd = new Random();<BR> for (int iLoop = 0; iLoop < iterations; iLoop++)<BR> {<BR> // draw the pixel<BR> bitmap.SetPixel(current.X, current.Y, Color.Red);<BR><BR> // Choose our next pixel<BR> switch (rnd.Next(3))<BR> {<BR> case 0:<BR> current.X -= (current.X - top.X) / 2;<BR> current.Y -= (current.Y - top.Y) / 2;<BR> break;<BR><BR> case 1:<BR> current.X -= (current.X - bottomLeft.X) / 2;<BR> current.Y -= (current.Y - bottomLeft.Y) / 2;<BR> break;<BR><BR> case 2:<BR> current.X -= (current.X - bottomRight.X) / 2;<BR> current.Y -= (current.Y - bottomRight.Y) / 2;<BR> break;<BR> }<BR> }<BR><BR> // Save the image to the OutputStream<BR> Response.ContentType = "image/jpeg";<BR> bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);<BR><BR> // clean up...<BR> bitmap.Dispose();<BR> }<BR><BR><BR> void Page_Load(Object senter, EventArgs e)<BR> {<BR> Serpinski(200,200, 10000);<BR> }<BR></script>When you try to view the page through your browser and do a View/Source, what do you see? Also, when you view it through your browser and you click on File/Properties what is the Type? (I'm assuming you're using IE - are you using Netscape?)<BR><BR>Also, are you using ASP.NET v1.0?This is great!! I see all my source code as it is when I do view/source. I am not sure what is going on. I see the same behaviour with many examples I am trying. <BR><BR>File/Properties ->Protocol - HyperText Transfer Protocol<BR> Type - ASPX File<BR> Connection - Not Encrypted<BR> Address - http://chinnam/LearnC/TriFractal.aspx <BR><BR> <BR> <BR>That is, are you running Windows 2000 or Windows XP Pro and have installed the .NET Framework?When I try to view any .ASPX file, I see source code in my browser.<BR>When I build the project, it shows .ASPX.CS, .ASPX.VB getting created.<BR><BR>It shows that project got built without any errors.<BR><BR>I have installed PWS 5.0/IIS from W2K professional CD before installing it from .NET BETA2 DVD.<BR><BR>.NET beta1 worked fine on this machine. I have removed Beta1 before trying Beta2. <BR><BR>Iam using <BR><BR>Browser : IE6.0<BR>Software : Microsoft Visual Studio.Net<BR> .Net framework Beta2 DVD(Includes .net readiness tools and<BR> resources)<BR>Operating system : Windows2000 Professional<BR><BR>IIS : 5.0(installed before .NET, SDK)<BR><BR>Please help me with this<BR><BR>
 
Back
Top