Solved

Detect if Visual Studio 2012  app is running from localhost

Posted on 2014-11-02
6
197 Views
Last Modified: 2014-11-03
I can run my app either from the localhost or from the server.

I need code to identify where the app is running from.
My test is:
if (context.Request.Url.ToString().StartsWith("http://localhost"))

This returns "".

Is there another way?

Thanks
0
Comment
Question by:Dovberman
  • 3
  • 3
6 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 40419608
0
 

Author Comment

by:Dovberman
ID: 40419974
I am using c#.

   Boolean blnLocal = true ;
     
What is the proper syntax?      
  ???          blnLocal = (System.Web.HttpRequest.

Thanks
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 40420189
blnLocal = (System.Web.HttpRequest.isLocal);
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Dovberman
ID: 40420202
blnLocal = (System.Web.HttpRequest.isLocal);

Error      4      'System.Web.HttpRequest' does not contain a definition for 'isLocal'      C:\Users\David\Documents\Visual Studio 2012\Projects\StockPickerMax\StockPickerMax\Admin\MaintainDataDaily.aspx.cs      369      48      StockPickerMax
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
ID: 40420311
sorry, should be

blnLocal = (Request.isLocal);

example - http://www.4guysfromrolla.com/articles/082609-1.aspx
0
 

Author Comment

by:Dovberman
ID: 40420408
Thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now