Solved

Detect if Visual Studio 2012  app is running from localhost

Posted on 2014-11-02
6
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

688 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