Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 8th, 2007, 04:32 AM
Registered User
Join Date: Oct 2007
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

Old October 8th, 2007, 11:20 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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

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

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