473,591 Members | 2,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open New Browser on Error

Hi
I have the following code to write an error file and it is supposed to open
the HTML file in a browser when an error occurs. It creates the file Ok but
doesn't open the new browser and doesn't give me any errors.

Tim

FileStream file = new FileStream(@"C: \errors\error.h tm",
System.IO.FileM ode.OpenOrCreat e);
StreamWriter sw = new StreamWriter(fi le);
sw.Write(strHtm l.ToString());
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
sw.Close();
file.Close();
Nov 17 '05 #1
6 1548
Try closing the file before you start the browser.

You may also need to use sw.Flush();

sw.Close();
file.Close();
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:lH******** ***********@new s20.bellglobal. com...
Hi
I have the following code to write an error file and it is supposed to
open the HTML file in a browser when an error occurs. It creates the file
Ok but doesn't open the new browser and doesn't give me any errors.

Tim

FileStream file = new FileStream(@"C: \errors\error.h tm",
System.IO.FileM ode.OpenOrCreat e);
StreamWriter sw = new StreamWriter(fi le);
sw.Write(strHtm l.ToString());
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
sw.Close();
file.Close();

Nov 17 '05 #2
I tried that Jim, both with and without sw.Flush(), but still no luck. Any
other ideas?

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OE******** ******@tk2msftn gp13.phx.gbl...
Try closing the file before you start the browser.

You may also need to use sw.Flush();

sw.Close();
file.Close();
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:lH******** ***********@new s20.bellglobal. com...
Hi
I have the following code to write an error file and it is supposed to
open the HTML file in a browser when an error occurs. It creates the file
Ok but doesn't open the new browser and doesn't give me any errors.

Tim

FileStream file = new FileStream(@"C: \errors\error.h tm",
System.IO.FileM ode.OpenOrCreat e);
StreamWriter sw = new StreamWriter(fi le);
sw.Write(strHtm l.ToString());
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
sw.Close();
file.Close();


Nov 17 '05 #3
Does typing C:\errors\error .htm from a command prompt work?

The following code works fine on my system.

private void Form1_Load(obje ct sender, System.EventArg s e)

{

String strHtml = "<html><body>Te sting</body></html>";

FileStream file = new FileStream(@"C: \errors\error.h tm",

System.IO.FileM ode.OpenOrCreat e);

StreamWriter sw = new StreamWriter(fi le);

sw.Write(strHtm l.ToString());

System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

sw.Close();

file.Close();

}

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:cW******** ***********@new s20.bellglobal. com...
I tried that Jim, both with and without sw.Flush(), but still no luck. Any
other ideas?

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OE******** ******@tk2msftn gp13.phx.gbl...
Try closing the file before you start the browser.

You may also need to use sw.Flush();

sw.Close();
file.Close();
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:lH******** ***********@new s20.bellglobal. com...
Hi
I have the following code to write an error file and it is supposed to
open the HTML file in a browser when an error occurs. It creates the
file Ok but doesn't open the new browser and doesn't give me any errors.

Tim

FileStream file = new FileStream(@"C: \errors\error.h tm",
System.IO.FileM ode.OpenOrCreat e);
StreamWriter sw = new StreamWriter(fi le);
sw.Write(strHtm l.ToString());
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
sw.Close();
file.Close();



Nov 17 '05 #4
I can open it from the command line but in the code it doesn't work. I am
running a C# web application in debug mode - would this make any difference?

Tim
"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OH******** ******@TK2MSFTN GP09.phx.gbl...
Does typing C:\errors\error .htm from a command prompt work?

The following code works fine on my system.

private void Form1_Load(obje ct sender, System.EventArg s e)

{

String strHtml = "<html><body>Te sting</body></html>";

FileStream file = new FileStream(@"C: \errors\error.h tm",

System.IO.FileM ode.OpenOrCreat e);

StreamWriter sw = new StreamWriter(fi le);

sw.Write(strHtm l.ToString());

System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

sw.Close();

file.Close();

}

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:cW******** ***********@new s20.bellglobal. com...
I tried that Jim, both with and without sw.Flush(), but still no luck. Any
other ideas?

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OE******** ******@tk2msftn gp13.phx.gbl...
Try closing the file before you start the browser.

You may also need to use sw.Flush();

sw.Close();
file.Close();
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:lH******** ***********@new s20.bellglobal. com...
Hi
I have the following code to write an error file and it is supposed to
open the HTML file in a browser when an error occurs. It creates the
file Ok but doesn't open the new browser and doesn't give me any
errors.

Tim

FileStream file = new FileStream(@"C: \errors\error.h tm",
System.IO.FileM ode.OpenOrCreat e);
StreamWriter sw = new StreamWriter(fi le);
sw.Write(strHtm l.ToString());
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
sw.Close();
file.Close();



Nov 17 '05 #5
Yes that would make a huge difference!

Web applications don't interact with the server desktop and therefore won't
launch the browser at the server.

If you are trying to use Process.Start on the client's browser, that won't
work either because of security.

The C# code is running inside of IIS at the server, not the client.

To open the error log in the browser:

Either use Response.Redire ct to a server url that contains your error log

Or

Do a Resonse.Write of the file contents.

Or

use Javascript to do a window.open(err orurl)
"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:ck******** ************@ne ws20.bellglobal .com...
I can open it from the command line but in the code it doesn't work. I am
running a C# web application in debug mode - would this make any
difference?

Tim
"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OH******** ******@TK2MSFTN GP09.phx.gbl...
Does typing C:\errors\error .htm from a command prompt work?

The following code works fine on my system.

private void Form1_Load(obje ct sender, System.EventArg s e)

{

String strHtml = "<html><body>Te sting</body></html>";

FileStream file = new FileStream(@"C: \errors\error.h tm",

System.IO.FileM ode.OpenOrCreat e);

StreamWriter sw = new StreamWriter(fi le);

sw.Write(strHtm l.ToString());

System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

sw.Close();

file.Close();

}

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:cW******** ***********@new s20.bellglobal. com...
I tried that Jim, both with and without sw.Flush(), but still no luck.
Any other ideas?

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OE******** ******@tk2msftn gp13.phx.gbl...
Try closing the file before you start the browser.

You may also need to use sw.Flush();

sw.Close();
file.Close();
System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:lH******** ***********@new s20.bellglobal. com...
> Hi
> I have the following code to write an error file and it is supposed to
> open the HTML file in a browser when an error occurs. It creates the
> file Ok but doesn't open the new browser and doesn't give me any
> errors.
>
> Tim
>
> FileStream file = new FileStream(@"C: \errors\error.h tm",
> System.IO.FileM ode.OpenOrCreat e);
> StreamWriter sw = new StreamWriter(fi le);
> sw.Write(strHtm l.ToString());
> System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
> sw.Close();
> file.Close();
>



Nov 17 '05 #6
Thanks Jim,

I am going to try that.

Tim

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
Yes that would make a huge difference!

Web applications don't interact with the server desktop and therefore
won't launch the browser at the server.

If you are trying to use Process.Start on the client's browser, that won't
work either because of security.

The C# code is running inside of IIS at the server, not the client.

To open the error log in the browser:

Either use Response.Redire ct to a server url that contains your error log

Or

Do a Resonse.Write of the file contents.

Or

use Javascript to do a window.open(err orurl)
"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:ck******** ************@ne ws20.bellglobal .com...
I can open it from the command line but in the code it doesn't work. I am
running a C# web application in debug mode - would this make any
difference?

Tim
"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OH******** ******@TK2MSFTN GP09.phx.gbl...
Does typing C:\errors\error .htm from a command prompt work?

The following code works fine on my system.

private void Form1_Load(obje ct sender, System.EventArg s e)

{

String strHtml = "<html><body>Te sting</body></html>";

FileStream file = new FileStream(@"C: \errors\error.h tm",

System.IO.FileM ode.OpenOrCreat e);

StreamWriter sw = new StreamWriter(fi le);

sw.Write(strHtm l.ToString());

System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");

sw.Close();

file.Close();

}

"Tim Cowan" <ti**@peopletog o.com> wrote in message
news:cW******** ***********@new s20.bellglobal. com...
I tried that Jim, both with and without sw.Flush(), but still no luck.
Any other ideas?

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:OE******** ******@tk2msftn gp13.phx.gbl...
> Try closing the file before you start the browser.
>
> You may also need to use sw.Flush();
>
> sw.Close();
> file.Close();
> System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
>
> "Tim Cowan" <ti**@peopletog o.com> wrote in message
> news:lH******** ***********@new s20.bellglobal. com...
>> Hi
>> I have the following code to write an error file and it is supposed
>> to open the HTML file in a browser when an error occurs. It creates
>> the file Ok but doesn't open the new browser and doesn't give me any
>> errors.
>>
>> Tim
>>
>> FileStream file = new FileStream(@"C: \errors\error.h tm",
>> System.IO.FileM ode.OpenOrCreat e);
>> StreamWriter sw = new StreamWriter(fi le);
>> sw.Write(strHtm l.ToString());
>> System.Diagnost ics.Process.Sta rt(@"C:\errors\ error.htm");
>> sw.Close();
>> file.Close();
>>
>
>



Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
8825
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page (same folder). The cookie is not received. Can someone explain why? I worked around this by adding a cache-control header with a value of no-cache. This fixes the problem. Unfortunately that causes another problem with Internet Explorer...
10
11211
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#" onClick="window.open('/cgi-bin/displayimage.cgi?/store/demo/image.jpg&YOUR+PRODUCT%27<b>S+NAME+GOES', 'fullimage', 'WIDTH=420,HEIGHT=405,status=0')"> The original window should not reload, but is, and I have tested it with both version 4.72 and 7.02, and they both do it. IE does not do it....
2
2902
by: Jason Morehouse | last post by:
Hello, Anyone know if it's possible to speak with the server via xmlhttp.open while the browser is doing a post -- file upload in this case: <form enctype="multipart/form-data" action="product" method="post" name="product" onSubmit="do_action_form(); return true;"> .... <script> // .. setup xmlhttp here.
6
6966
by: VK | last post by:
I'm using window.open method in my script to open poup window. Recently Internet Explorer users reported that the script crashes on their machine with different runtime errors. See the bug: <http://support.microsoft.com/default.aspx?scid=kb;en-us;888021> The statement like myPopup = window.open(args); gives you runtime error and halts the script execution *if a 3rd party
0
1145
by: awsok fakry via .NET 247 | last post by:
Hi All, I am trying to open a new instance of IE at the start of my C# application. When user press Start Recording... My applicaiton will close that specific instance of IE and Open a fresh IE, but if that instance is closed manually, then the App must still be able to open a new fresh IE... It give me the following erro message: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ieObjTest.exe ...
18
3320
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
10
6094
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the code below which when executed generates the following error message: 'There is already an open datareader with this command which must be closed first' Private Sub MainMenu_Load(ByVal sender As System.Object, ByVal e As
2
12722
by: LayneMitch via WebmasterKB.com | last post by:
Hello. I posted this earlier with the full code of the JavaScript file I'm trying to open. I'm posting this again, because the file is not the problem. I seem to be having a 'windows' problem w/ Window Script Host. While this is more of a computer support based problem, I was hoping that someone had any knowledge on how to resolve this situation. The error message I'm getting is:
0
7934
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7870
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8236
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8362
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8225
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6639
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5732
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.