.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

WCF Detecting context

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :WCF

Hi.  I'm trying to find out how I can detect the context of my host so I can open the appropriate configuration - I need to tell whether the code is running self hosted (so I can use ConfigurationManager.OpenExeConfiguration) or in IIS(System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration)

I also want to get the url within which my self hosted app is listening.

When I'm running self hosted and I call through a bro

View Complete Post

More Related Resource Links

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

Detecting Edit or Insert Page


I am coding a .cs file that handles the metadata for a particular table. I am putting a custom validation that allows me to update or insert only if the PubMedID is not already in the database. This would be easy except that the PMID should also be allowed to be null as some of the references in the database were not from PubMed. So i perform a query on the database to see if there is already an identical PMID in the database. This works great when using Insert. However, when using Edit, it does not. The PMID is already in the database because the one currently being edited has the same PMID!!! So I know exactly how to change my query etc. However, I do not know how to tell from inside this Edit/Insert agnostic page, which one it is being called from. Thanks for your help! 

Detecting PPC device on startup page to redirect?

I was wondering (since a search didn't find any posts) if there is a way for my startup page to detect what kind of device (PocketPC or web browser specifically) is loading the page and if it is a PocketPC, then redirect to the mobile pages? I will only be using PocketPC's exclusively as a mobile device.

Thanks for any suggestions!

Cutting Edge: Context-Sensitive Feedback with AJAX


Beyond progress bars: talking to server-side apps with ASP.NET AJAX.

Dino Esposito

MSDN Magazine July 2007

Cutting Edge: Context-Sensitive PictureBox Controls


Great ideas are timeless. A long time ago in Microsoft Systems Journal Paul DiLascia demonstrated a neat trick to display context-sensitive tooltips floating over pictures. As the user moved the mouse over the picture, the tooltip control updated its text to reflect the name of the pointed figure.

Dino Esposito

MSDN Magazine July 2006

Cutting Edge: Adding a Context Menu to ASP.NET Controls


Although the context menu is a common element of most desktop applications, it is still fairly uncommon in Web application names because it doesn't map well to a server-based technology like ASP. NET.

Dino Esposito

MSDN Magazine February 2005

Resource Leaks: Detecting, Locating, and Repairing Your Leaky GDI Code


Leaks are possible, even in robust Windows-based applications. As bugs go, leaks are some of the most difficult to find, especially when they occur in graphics device interface (GDI) objects and menus. While free and third-party tools exist to detect such leaks, it is usually difficult to make the connection between the numeric handle value returned by the tool, and a bitmap or menu in your program. This can limit the usefulness of these tools. Custom tools can be built that detect, track down, and eradicate GDI and menu leaks. Here, three such tools are built using well-known and documented APIs.

Christophe Nasarre

MSDN Magazine March 2001

Detecting mobile device user agents in ASP.NET (Android)



Last week Android updated their software (changed the display from 480px to 800px) so all the mobile tweaks we made for our apps are no longer work on Droid Phones.

I would need to identify the User Agent(e.g. Android) and switch style sheets depending. (We don't want to redirect to another page, just switch style sheets).

Anybody know any lightweight solution ?

Thanks in Advance.

(we were using 480px pixels to identify if the user was coming from iPhone or Android and switched stylesheets accordingly.  If I changed it to 800px some desktop monitors and the iPad would see the mobile version and not the desktop version. Not good.)



Detecting networking devices by asp.net program in I.P ranger


I have a project in which i want to detect networking devices in a user-defined I.P Range.

I know i have to use SNMP layer in order to accoplish this, but i don't how to do about it ?

Is there anyone who can guide me in a right direction? How it is possible to do all these things from asp.net web based application ?

CS0103: The name 'Helper' does not exist in the current context


Hey i have a Class named Helper.cs inside my App_Code folder.

And i get this error:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'Helper' does not exist in the current context

Source Error:

Line 26:         {
Line 27:             SqlConnection con = new SqlConnection(Helper.ConnectionString());

The name 'User' does not exist in the current context.


Hey guys,

I've got a literal control to display the username of the user logged into our companies intranet system, originally I had a LoginName control but couldn't get strip to remove the domain from the username (as the format is domainname\username) so I'm trying it this way.

    protected void Page_Load(object sender, System.EventArgs e)
        string[] Parts = User.Identity.Name.Split("\\");

        if (Parts.Length == 2)
            loginName.Text = Parts[1];
            loginName.Text = User.Identity.Name;


    protected void Page_Load(object sender, System.EventArgs e)
        string[] Parts = User.Identity.Name.Split("\\");

Login control - Controls do not exist in current context

Hi all,Trying to set up the Login control as a User control, but none of the controls exist in the current context?None of my code below is recognised? What's going on here please? I've rebuilt the solution many times.if (Membership.ValidateUser(this.UserName.Text, this.Password.Text))        {            FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);        }        else        {             Msg.Text = "Login failed. Please check your user name and password and try again.";        }
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend