Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 4th, 2004, 11:45 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Content-type = text/html

Hi All,

I am trying to set a HTTP header to "text/html" and I am having no joy.

This is what I have so far... Am I far off? How can I do this?


using System;

class Hello
{
     static void Main()
     {
          Console.ContentType = "text/html";
          Console.WriteLine("Hello World");
     }
}

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old December 4th, 2004, 01:00 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,084
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi tarran,

What exactly is the point of setting the ContentType of the console in a console application???

I think you're mixing COnsole Applications and Web applications...


What exactly are you trying to accomplish?

Imar
Reply With Quote
  #3 (permalink)  
Old December 4th, 2004, 05:18 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Firstly, thank you for your reply.

I am trying to make a CGI application but I don't want to use ASP.NET - Just straight c#... I am rather new to C# and maybe there is a better way to do this however If I wanted to do the same thing in c++ i would do:

#include <iostream.h>

int main(){
    cout << "Content-type: text/plain" << endl << endl
    << "Hello World";
}

Am I going about this the wrong way? How should I be doing this remembering I don't want to use ASP.NET, only c#?

Thanks once again.
Tarran

Reply With Quote
  #4 (permalink)  
Old December 5th, 2004, 08:36 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,084
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi again,

Well, a Console application won't cut it, as it will only run like a console application. I don't think you can tell IIS or any other Web server to redirect requests to the console.

What you probably need to create is your own custom HttpHandler that can run as an ISAPI extension . You can configure IIS applications to redirect requests to your HttpHandler, allowing you to bypass or enhance the ASP.NET functionality.
A while ago I created an HttpHandler to build a more powerful redirector that redirected Web sites to another server, while maintaining QueryString variables and logging the redirects. It was as easy as inheriting the right classes / implementing interfaces, and adding a few lines of code.

Here's the MSDN start page for HttpHandlers: http://msdn.microsoft.com/library/de...asp?frame=true

Another interesting article: http://www.15seconds.com/issue/020417.htm

Searching Google for HttpHandlers .NET will give you quite some interesting results.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Content-type: text/html\n\n - needed every time? crmpicco Perl 2 November 13th, 2006 11:09 AM
content="text/html; charset=iso-8859-1" crmpicco HTML Code Clinic 6 June 17th, 2005 05:09 AM
How To Type the text of html tag in TextBox 6cet6 ASP.NET 1.0 and 1.1 Basics 3 November 6th, 2003 05:30 AM
Retrive text from input type field of html file?? bikash Javascript 10 July 30th, 2003 04:50 AM



All times are GMT -4. The time now is 06:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.