Solved

Detect if Visual Studio 2012  app is running from localhost

Posted on 2014-11-02
6
199 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 33

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 33

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 33

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

803 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