Home > Microsoft .Net Development Tips > C# Development > Web enable a C# program
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

C# DEVELOPMENT

Web enable a C# program


Kamran Shakil
12.19.2002
Rating: -3.75- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Let other users know how useful this tip is by rating it below. Got a tip or code of your own you'd like to share? Submit it here!


First we need a Web server. Apache is the most popular, practical and easily configurable Web server available on the Internet. It can be downloaded from www.apache.org. Apache runs on most operating systems. This will also work on IIS.

After installation on the network drive or local drive, we see a number of subdirectories among which we see cgi-bin and htdocs. The cgi-bin subdirectory is used to contain executable files, while htdocs is used to contain HTML files. When your installation and setup configuration is successful (for help see the Web site), type the address as http:/127.0.0.1 and press enter. We see a default page placed in the htdocs directory and see the apache server running. Change the htdocs subdirectory and create an HTML file new.html to display a form page as follows:

Now save this file! Open up your favourite browser and type http://127.0.0.1/new.html, then press enter. We see results! A button with a text (caption) search, is on the page.

Now we get down to business. Let us try out a C# code snippet that, when a user c


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
C# Development
Let Microsoft StyleCop tame your wild C#
Picking a .NET smart client communications technology
LINQ beyond queries: Strong-typed refection
Book excerpt: An introduction to DSL tools
Assembly versioning in the .NET Framework 2.0
Book excerpt: Creating graphical output using the .NET Compact Framework
On Extension Methods in C# and .NET Framework 3.5
Generate RSA public and private keys, export to XML
Book excerpt: Upgrading to Visual Studio 2005
Learning .NET: Tips for getting started with .NET development

ASP.NET Development
How to use jQuery to solve Javascript browser compatibility problems
How to write an out-of-browser Silverlight 3 application in 3 steps
Silverlight 3 beta SDK download lets developers try new RIA features
Visual Studio's IntelliSense for jQuery doesn't autocomplete correctly
Dundas Map for .NET kicks up geographic visualization
Return to CodePlex: Into the Sandcastle…
VBScript Tutorial
Use PHP with Visual Studio to create Web sites
Visual Studio Team System Add-ins: Conchango Scrum for Team System and Scrum Dashboard
Visual Studio 2008 and .NET Framework 3.5 SP1 introduces ADO .NET Entity Designer

ASP.NET development best practices
Introduction to ASP.NET's Model View Controller (MVC) Design Pattern
Silverlight, Ajax components require different approach to UI
LINQ Learning Guide: LINQ and Web applications
VB code download home page
VB code: File manipulation downloads
Localization practices for .NET 2.0: It's still about the architecture
Creating custom ASP.NET 2.0 profile providers
.NET development in the trenches
Microsoft developers balancing age-old issues, barrage of new technology
SearchVB.com's Podcast Page

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
136 browser colors with names  (SearchWinDevelopment.com)
ASP.NET  (SearchWinDevelopment.com)
browser  (SearchWinDevelopment.com)
Document Object Model  (SearchWinDevelopment.com)
domain name  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


licks on the search button, a C# program loads and executes.

Make a file new.cs and write the following lines into it:

Save this file. Using csc.exe compile it, turn it into an .exe, and put it in proper Apache's cgi-bin subdirectory, or allow execute permissions if using IIS.

Now, for this, we need to modify a few things to our new.html, as follows:

We open up the browser type in the URL http://127.0.0.1/new.html. We see what? Not "hi it's me," but an "Internal Server Error"! Do not panic. Our new.cs code just needs slight modification too! See the new code below:

Now if we execute it the same way into the browser, we see no errors. Yes! You have just successfully, without spending even a quarter of an hour, made a Web-enabled program in C#.

Last but not the least, here is something for better understanding. Note the code below:

In the content-type, instead of HTML, I changed it to plain. So what does that output to the monitor? Don't be surprised. It won't flash an error. Rather, forthcoming lines containing HTML tags won't take effect and will behave as simple text.

Hope you didn't find the reading time hard on you! Happy coding.


Source: DotNetExtreme.com

Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts