Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 8th, 2007, 04:32 AM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Application is Web Or Windows! How to Identify?


I am using vb.net & asp.net 2005 and have a Windows Service and a Web Application.

I have a class named Utilities, object of which is created in the Windows Service (installed on one application server) and also from a Web Page (installed on other web server).

In the older versions of my project I used to implement #If Web = 1/0 Then # compiler directives to compile and build code that was specific to my app server and for my web server and install those specific builds on their servers respectively.

Now a decision has been taken that we will use the Web = 1 directive ONLY (A single build for app and web). But the differentiated Codes must be maintained. The condition I am trying to differentiate here is, if it’s a web application that is calling the Utilities code then I must use HTTP Cache otherwise if it’s a windows service (win app) I make calls to database to fetch required values.

hence I need an alternative approach to the problem than Web = 1 directive.

A very layman approach would be passing a parameter (say IsWindows = True) to Utilities while making Windows Application calls. So that it would tell the code if a windows service is calling it or a web page.

But do we have anything more sophisticated e.g. something in ApplicationServices namespace that tells me whether the base application is windows or web?

I do not want to use AssemblyName or path properties as they would be very crude to use.

What about creating an object of ApplicationServices.WebUser class … it should be equal to nothing when a windows application calls it … right?

If no then anything else which you guys can reckon?


Vinit Sankhe

Reply With Quote
  #2 (permalink)  
Old October 8th, 2007, 11:20 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Can't you check HttpContext.Current?



Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote

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
Web Application OR Windows Application adesilva .NET Framework 2.0 2 May 4th, 2007 07:12 AM
How can i debug my web/windows application? vijaykumartaduri ASP.NET 2.0 Professional 1 March 20th, 2007 06:40 AM
open a windows application from a web page eresina HTML Code Clinic 1 May 9th, 2005 02:00 PM
How to create pop up windows in web application? samlow82 .NET Web Services 4 April 5th, 2005 11:30 PM
Web application Vs Windows Application Ned .NET Web Services 2 January 20th, 2004 01:27 PM

All times are GMT -4. The time now is 05:48 AM.

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